function replace(string,text,by) {
		// Replaces text with by in string
		var strLength = string.length, txtLength = text.length;
		if ((strLength == 0) || (txtLength == 0)) return string;
		var i = string.indexOf(text);
		if ((!i) && (text != string.substring(0,txtLength))) return string;
		if (i == -1) return string;
		var newstr = string.substring(0,i) + by;
		if (i+txtLength < strLength)
		newstr += replace(string.substring(i+txtLength,strLength),text,by);
		return newstr;
	}
	function CheckQuantityBox(){
		if(document.DetailsForm.quantity.value <= 0 || isNaN(document.DetailsForm.quantity.value)){
			alert("Please enter a quantity value larger than 0.");
			return false;
		}
	
	}
	//function Send2Friend(productID){
	//	ApplicationWindow = window.open("index.cfm?event=Send2Friend&ProductID=" + productID,"mywindow","toolbar=no,menubar=no,scrollbars=yes,location=no,status=yes,height=600,width=600,resizable=yes");
	//	return false		
	//}
	function AddAReview(productID){
		ReviewWindow = window.open("index.cfm?event=AddAReview&ProductID=" + productID,"ReviewWindow","toolbar=no,menubar=no,scrollbars=yes,location=no,status=yes,height=350,width=510,resizable=yes");
		return false		
	}
	function AllCustomerReviews(productID){
		AllReviewsWindow = window.open("index.cfm?event=AllCustomerReviews&ProductID=" + productID,"AllReviewsWindow","toolbar=no,menubar=no,scrollbars=yes,location=no,status=yes,height=600,width=600,resizable=yes");
		return false		
	}
	function ChangePrice(){
		var theIndex = document.DetailsForm.Option1.selectedIndex;
		var DropBoxVal = document.DetailsForm.Option1[theIndex].text;
		if(DropBoxVal.indexOf("$") == -1) {
			return;
		}
		else{
			var DollarPos = DropBoxVal.indexOf("$");
			var ProductPriceVal = DropBoxVal.substring(eval(DollarPos+1),DropBoxVal.length);
			document.getElementById("ProductPrice").innerHTML = "$"+cent(ProductPriceVal);	
		}
	}
	function cent(amount) {
		// returns the amount in the .99 format 
		amount -= 0;
		amount = (Math.round(amount*100))/100;
		return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
	}
	function Send2Friend(productID){
		SendFriendWindow = window.open("index.cfm?event=Send2Friend&ProductID=" + productID,"SendFriendWindow","toolbar=no,menubar=no,scrollbars=yes,location=no,status=yes,height=600,width=600,resizable=yes");
		return false		
	}

	function SwitchImages(TheImageSource,obj) {
		
		//Set the source image (Image clicked) information
		var SourceImage = TheImageSource;
		var SourceImageAlt = obj.alt;
						
		//Switch the clicked alt image with the detail image 		
		SourceImage = replace(SourceImage,'Thumbnail','Detail');
							
		//Set the destination detail image to be the clicked alt image
		document.DetailsForm.DetailImage.src = SourceImage;		
		document.DetailsForm.DetailImage.alt = SourceImageAlt;	
		
		SourceImage = replace(SourceImage,'Detail','Enlarged');
		document.getElementById("EnlargeLinkID").href = SourceImage;	
	}
	function ShowOptions(productID, optionID){
		OptionWindow = window.open("index.cfm?event=ShowOptions&ProductID=" + productID + "&OptionID=" + optionID,"OptionWindow","toolbar=no,menubar=no,scrollbars=yes,location=no,status=yes,height=480,width=200,resizable=yes");
		return false		
	}
	function ShowInfoPop(productID, attributeID){
		InfoWindow = window.open("index.cfm?event=ShowInfoPop&ProductID=" + productID + "&attributeID=" + attributeID,"InfoWindow","toolbar=no,menubar=no,scrollbars=yes,location=no,status=yes,height=300,width=400,resizable=yes");
		return false		
	}
	
