// Scripts for handling thumbnail gallery
// Assumptions: 
// big image has id named productImage
thumbnailGallery = { // try to get this assumptive info from somewhere else that can be dynam updated
//rootFileName: 'three-five-hard-drive-', // assumes this base file name for frame images
//imagesDirectory: '/EdgeTechCorp_EComm_Live (Beta)/Storefront/Assets/images/harddrive/', // directory for images
imageGalleryLinks: [],
init:function() {
	if (!document.getElementsByTagName || !document.getElementById) { return false; }
	/* get links that are gallery elements */
	thumbnailGallery.imageGalleryLinks = document.getElementsByTagName("a");
	for(var i=0; i<thumbnailGallery.imageGalleryLinks.length; i++) {
		if (DOMhelp.cssjs('check', thumbnailGallery.imageGalleryLinks[i], 'galleryLink')) {
			// on hover over a gallery link call show image
			DOMhelp.addEvent(thumbnailGallery.imageGalleryLinks[i], 'mouseover', thumbnailGallery.showImage, false);
			DOMhelp.addEvent(thumbnailGallery.imageGalleryLinks[i], 'click', thumbnailGallery.cancelThisClick, false);
		}
	}
},
showImage:function(e) {
	var obj = DOMhelp.getTarget(e);
	/* assume we are looking for an anchor tag and keep going up parent until find it */
	var found = 0;
	while (obj!= 'NULL' && found == 0) {
		if (obj.nodeName.toLowerCase() != 'a') {
			obj = obj.parentNode; 
			found = 1;
		}
	}
	// get the big image container and if it not here then exit return true to follow click
	if(!document.getElementById("productImage")) { return true; }
	var productImage = document.getElementById("productImage");
	// get the links href which is the source file of the big image
	var source = obj.getAttribute("href");
	// set the image container source to be this href value
	productImage.setAttribute("src", source);
},
cancelThisClick:function(e) {
	DOMhelp.cancelClick(e);
	return false;
}

}	
DOMhelp.addEvent(window,'load', thumbnailGallery.init, false);