// This changePhoto Function changes image 
// with selected image from drop-down list
// Now integrates with Dynamic List Script

// Version 1.10

function changePhoto(thatForm, thatElement, strProductPhotoName){
	// Changes a photo to selected product photo
		
	var strProductPhotoNew = thatElement.value;
	var strProductTemp = strProductPhotoNew;
	var intArrayNameEnd = 0;
	var intArrayNameStart = 0;
	var blnImage = false;
				
	// Loops each text character in strProductPhotoNew and retrieves correct image name
	for (var i=0;i<strProductTemp.length;i++){
		if (strProductTemp.substring(i, i+1)=='('){intArrayNameStart = (i+1)};
		if (strProductTemp.substring(i, i+1)==')'){intArrayNameEnd = (i)};

		if (intArrayNameEnd>0){
			strProductPhotoNew = strProductTemp.substring(intArrayNameStart, intArrayNameEnd);
			intArrayNameEnd = 0;
			intArrayNameStart = 0;
			blnImage = true;
		}
	}

	if (blnImage == false) strProductPhotoNew = strNoImage;
	if (strProductPhotoNew == ':0.00') strProductPhotoNew = strNoImage;

	if (document.images){
		document.images[strProductPhotoName].src = strProductPhotoNew;
	}else{
		document.elements[strProductPhotoName].src = strProductPhotoNew;
	}
}