//*****************************************************************************
// Author:	Page8 Studios - Jackie Apshire Jr.
// Date:	5/14/2008

// The purpose of this script is to allow the implementation of
// the Highslide image resizing script in the AmeriCommerce system.
// It allows the user to only have to supply a single image for each
// product by tapping into AmeriCommerce's "Image Resizer" system.
// The script has also been test with both IE 7 and FF 2.0.0.14.
//*****************************************************************************

function getHighSlideFullImage(oHighSlideLink){
	try{
		var oThumbImage = oHighSlideLink.getElementsByTagName("img")[0];
		var sDefaultImagePath = "/store/images/default-product-image.jpg"; // AC's default image when non can be found.
		var sFullImagePath = "";
		
		if(oThumbImage != null){
			//alert("Image found!");
			sFullImagePath = oThumbImage.src;
			//alert("Path: " + sFullImagePath);
			
			// Pull out just the image path
			var iStartOfPath = sFullImagePath.indexOf("?path=") + 6;
			var iEndOfPath = sFullImagePath.indexOf("&");
			sFullImagePath = sFullImagePath.substring(iStartOfPath, iEndOfPath);
			//alert("Final Path: " + sFullImagePath);
		}
		
		// Check to see if we found anything and if so then lets pass it to Highslide.
		// If not just send in AC's default image.
		if(sFullImagePath != "")
			oHighSlideLink.setAttribute("href", sFullImagePath);
		else
			oHighSlideLink.setAttribute("href", sDefaultImagePath);
			
	}
	catch(err){
		// Do Nothing
	}
	
	return hs.expand(oHighSlideLink);
}	
