window.onbeforeunload = function () {
   // This fucntion does nothing.  It won't spawn a confirmation dialog
   // But it will ensure that the page is not cached by the browser.
}
	function swapTab( id, img, anc ) {
		var st = document.getElementById("tabbed")
		st.src = '/images/build/' + img
		window.location.href = anc;
		document.getElementById("ProductDescription").style.display = 'none';
		document.getElementById("CakeSizeInformation").style.display = 'none';
		document.getElementById("CakeIngrediants").style.display = 'none';
		document.getElementById("Reviews").style.display = 'none';
		document.getElementById("Delivery").style.display = 'none';
		document.getElementById(id).style.display = 'block';
	}
	function updatePrice( oVal, obj ) {
  //Egg Free Sponge
  //Wheat/Gluton Free Sponge
	//Moist Light Sponge
	var oForm 		 = document.addtocart
	var oHoldPrice = oForm.holdingprice.value;
	var oRealPrice = oForm.price.value;
	var oCalc = 0;
		if(oForm.price.value=="0.00") {
			alert("please first select a size");
			oForm[obj].selectedIndex=0;
			}else{
				if(oForm[obj].value=="Moist Light Sponge" || oForm[obj].value=="") {
					oCalc = parseFloat(oHoldPrice);
					oForm.price.value = just(oCalc);
					document.getElementById("priceContainer").innerHTML = "Cake Price: &pound;" + just(oCalc);
					}
				if(oForm[obj].value=="Egg Free Sponge") {
					oCalc = parseFloat(oHoldPrice) + parseFloat((oHoldPrice*10)/100);
					alert("The Egg Free Sponge Option adds an additional £" + just(parseFloat((oHoldPrice*10)/100)) + " to the original cake price")
					oForm.price.value = just(oCalc);
					document.getElementById("priceContainer").innerHTML = "Cake Price: &pound;" + just(oCalc);
					}
				//alert(lTrim(oForm.flavours.value.toLowerCase()) + '\nvanilla sponge')
				if(oForm.flavours.value.toLowerCase()!="vanilla sponge" && oForm[obj].value=="Gluten Free Sponge") {
					oCalc = parseFloat(oHoldPrice) + parseFloat((oHoldPrice*50)/100);
					alert("The Gluten Free Sponge Option adds an additional £" + just(parseFloat((oHoldPrice*50)/100)) + " to the original cake price")
					oForm.price.value = just(oCalc);
					document.getElementById("priceContainer").innerHTML = "Cake Price: &pound;" + just(oCalc);
					}
				if(oForm.flavours.value.toLowerCase()=="vanilla sponge" && oForm[obj].value=="Gluten Free Sponge") {
					alert("Sorry but this option is not available on vanilla sponges");
					oCalc = parseFloat(oHoldPrice);
					oForm[obj].selectedIndex=0;
					oForm.price.value = just(oCalc);
					document.getElementById("priceContainer").innerHTML = "Cake Price: &pound;" + just(oCalc);
					}
		}	//if(document.addtocart.price.value=="0.00") {
	}
	
		function resertallselectmenu(id) {
			//var div = document.getElementById(id)
			//		var allTags = document.body.getElementsByTagName('select');
			//		var ids = [];
			//		for (var tg = 0; tg< allTags.length; tg++) {
			//		var tag = allTags[tg];
			//		if (tag.id) {
			//		document.getElementById[tag.id].selectedIndex = 0;
			//		document.getElementById(tag.id).disabled = (tag.id!="size") ? true : false ;
			//		ids.push(tag.id);
			//		}
			//		}
					
			var NumberOfSelectMenus = (document.getElementById("addtocart").getElementsByTagName("select").length);
				for( i=1; i<=NumberOfSelectMenus; i++ ) {
					document.getElementById("addtocart").getElementsByTagName("select")[(i-1)].selectedIndex =0;
				}

		}
	
	
		function releaseSelectMenu() {
			releaseThisMenu = 0
			var NumberOfSelectMenus = (document.getElementById("addtocart").getElementsByTagName("select").length);
				for( i=1; i<=NumberOfSelectMenus; i++ ) {
					if( !document.getElementById("addtocart").getElementsByTagName("select")[(i-1)].disabled ){
						releaseThisMenu = (releaseThisMenu+1)
					}
				}
				if( releaseThisMenu < NumberOfSelectMenus ) {
					document.getElementById("addtocart").getElementsByTagName("select")[releaseThisMenu].disabled = false;
				}
		}

		function resetLastMenu() {
			var NumberOfSelectMenus = (document.getElementById("addtocart").getElementsByTagName("select").length);
				for( i=2; i<=NumberOfSelectMenus; i++ ) {
					document.getElementById("addtocart").getElementsByTagName("select")[(i-1)].selectedIndex =0;
				}
		}
		
		function setPrice2( objIndex, oPrice ) {
			var oForm = document.addtocart;
			
			var tempPrice = oPrice.split(", ")
			//alert( tempPrice[objIndex-1] );
			oForm.holdingprice.value=just(tempPrice[objIndex]);
			oForm.price.value=just(tempPrice[objIndex]);
			document.getElementById("priceContainer").innerHTML = "Cake Price: &pound;" + just(tempPrice[objIndex]);
		}

		function setPrice( oPrice ) {
			var oForm = document.addtocart
			//alert(objIndex);
			//alert(oPrice);
			//var tempPrice = oPrice.split(", ")
			//alert( tempPrice[objIndex] );
			oForm.holdingprice.value=just(oPrice);
			oForm.price.value=just(oPrice);
			document.getElementById("priceContainer").innerHTML = "Cake Price: &pound;" + just(oPrice);
		}

		
		function showReviews() {document.getElementById('showReview').style.display = 'block';}
		
		function validateRadioButtonsFirst( oForm ) {
			//var correct = true;
			//var checked = false;
			//if(oForm.size.length == undefined)
				//for(i=0;i<=(oForm.size.length-1);i++) {
				//	if(oForm.size[i].checked){
				//		checked = true;
				//		break;
				//	}
				//}
				//correct = ( oForm.size.value != "" )
				//alert(correct)
				//if(!checked) { 
					//alert("Please choose a size of cake\nthis will determine the price of your cake")
					//correct = false; 
					//}
				//if(!correct) { alert("You must select a size option first") }
				//if(correct) {
					return validateForm(document.addtocart);
				}
				//return correct;
		//}