// Image Options Script
// Version 3.0
// Last Updated 31/08/07
// This product can be purchased from www.orderhistorysoftware.com

// Set-up Variables
var NoImage = "src=../images/noimage.gif";

// DO NOT EDIT BELOW THIS LINE
// -------------------------------------------------------------------------


// Main Functions
function ChangePhoto(thatElement, ProductPhotoName){
	// Changes a photo to selected product photo
		
	var ProductPhotoNew = thatElement.value;
	var ProductTemp = ProductPhotoNew;
	var NameEnd = 0;
	var NameStart = 0;
	var blnImage = false;
				
	// Loops each text character in ProductPhotoNew and retrieves correct image name
	for (var i=0;i<ProductTemp.length;i++){
		if (ProductTemp.substring(i, i+1)=='('){NameStart = (i+1)};
		if (ProductTemp.substring(i, i+1)==')'){NameEnd = (i)};

		if (NameEnd>0){
			ProductPhotoNew = ProductTemp.substring(NameStart, NameEnd);
			NameEnd = 0;
			NameStart = 0;
			blnImage = true;
		}
	}

	if (blnImage == false) ProductPhotoNew = NoImage;
	if (ProductPhotoNew == ':0.00') ProductPhotoNew = NoImage;

	if (document.images){
		document.images[ProductPhotoName].src = ProductPhotoNew;
	}else{
		document.elements[ProductPhotoName].src = ProductPhotoNew;
	}
}
