//*****************************************************************************
// 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.
//*****************************************************************************

function getHighSlideFullImage(oHighSlideLink){
	
	var oThumbImage = oHighSlideLink.getElementsByTagName("img")[0];
	var sFullImagePath = "/store/images/default-product-image.jpg"; // AC's default image when non can be found.
	
	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.
	oHighSlideLink.setAttribute("href", sFullImagePath);
	
	return hs.expand(oHighSlideLink);
}	
