var LOCAL_COST_DESCRIPTION = "Central Coast - $10";
var LOCAL_DELIVERY_TIME = "Next business day";
var ACT_COST_DESCRIPTION = "Canberra - $16";
var ACT_DELIVERY_TIME = "2 to 3 business days";
var NRTH_NSW_COST_DESCRIPTION = "Coffs Harbour, Northern Rivers - $16";
var NRTH_NSW_DELIVERY_TIME = "2 to 3 business days";
var PORT_MAC_COST_DESCRIPTION = "Port Macquarie - $12";
var PORT_MAC_DELIVERY_TIME = "2 business days";
var SYDNEY_COST_DESCRIPTION = "Sydney Metro, Wollongong, Newcastle - $12";
var SYDNEY_DELIVERY_TIME = "Next business day";
var SOTH_NSW_COST_DESCRIPTION = "Albury, Wagga Wagga - $19";
var SOTH_NSW_DELIVERY_TIME = "2 to 3 business days";
var REGIONAL_NSW_COST_DESCRIPTION = "Regional and Country NSW - $19";
var REGIONAL_NSW_DELIVERY_TIME = "2 to 3 business days";
var QLD_COST_DESCRIPTION = "Brisbane, Gold Coast, North Gate, Toowoomba - $19";
var QLD_DELIVERY_TIME = "2 to 3 business days";
var NRTH_QLD_COST_DESCRIPTION = "Wide Bay, Capricorn Coast, Mackay - $26";
var NRTH_QLD_DELIVERY_TIME = "3 to 4 business days";
var VIC_COST_DESCRIPTION = "Melbourne, Geelong, Bendigo, Wodonga - $19";
var VIC_DELIVERY_TIME = "2 to 3 business days";
var SA_COST_DESCRIPTION = "Adelaide, Mt Gambier - $26";
var SA_DELIVERY_TIME = "3 to 4 business days";
	
	function open_window(link,w,h) //opens new window
	{
		var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'newWin',win);
		newWin.focus();
	}

	function confirmDelete() //unsubscription confirmation
	{
		temp = window.confirm('{/literal}{$smarty.const.QUESTION_UNSUBSCRIBE}{literal}');
		if (temp) //delete
		{
			window.location="index.php?killuser=yes";
		}
	}

	function validate_custinfo() //validate customer information
	{
		//Billing information
		if (document.custinfo_form.first_name.value=="" || document.custinfo_form.last_name.value=="")
		{
			alert("Please input your full name");
			return false;
		}
		if (document.custinfo_form.email.value=="")
		{
			alert("Please input your email address");
			return false;
		}
		if (document.custinfo_form.phone.value=="")
		{
			alert("Please input your contact phone number");
			return false;
		}
		if (document.custinfo_form.address.value=="")
		{
			alert("Please input your address");
			return false;
		}
		if (document.custinfo_form.city.value=="")
		{
			alert("Please input your city/town");
			return false;
		}
		if (document.custinfo_form.zip.value=="")
		{
			alert("Please input your post code");
			return false;
		}
				
		//Delivery information
		if (document.custinfo_form.delivery_first_name.value=="" || document.custinfo_form.delivery_last_name.value=="")
		{
			alert("Please input the recipients full name");
			return false;
		}
		if (document.custinfo_form.delivery_address.value=="")
		{
			alert("Please input the delivery address");
			return false;
		}
		if (document.custinfo_form.delivery_city.value=="")
		{
			alert("Please input the delivery city/town");
			return false;
		}
		if (document.custinfo_form.delivery_zip.value=="")
		{
			alert("Please input the delivery post code");
			return false;
		}
		if (document.custinfo_form.delivery_area.value=="")
		{
			alert("Please input the delivery post code");
			return false;
		}

		return true;
	}
	
	function setDeliveryPrice() //set the delivery location
	{
		var svPostCode = document.custinfo_form.delivery_zip.value;
		
		if (svPostCode == "")
		{
			alert("Please input the delivery post code");
			document.custinfo_form.delivery_area.value = "";
			document.custinfo_form.preferred_delivery_date.value = "";
			return false;
		}
		var nPostCode = parseInt(svPostCode);
		
		if (nPostCode < 1999)
		{
			alert("Please input the delivery post code");
			document.custinfo_form.delivery_area.value = "";
			document.custinfo_form.preferred_delivery_date.value = "";
			return false;
		}
		
		//NSW Post Codes (2000)
		if (nPostCode > 1999 && nPostCode < 3000)
		{
			CheckNSWPostCodes(nPostCode);	
		}
		//QLD Post Codes (4000)
		/*else if (nPostCode > 3999 && nPostCode < 5000)
		{
			CheckQLDPostCodes(nPostCode);	
		}
		//VIC Post Codes (3000)
		else if (nPostCode > 2999 && nPostCode < 4000)
		{
			CheckVICPostCodes(nPostCode);	
		}
		//SA Post Codes (5000)
		else if (nPostCode > 4999 && nPostCode < 6000)
		{
			CheckSAPostCodes(nPostCode);	
		}*/
		else
		{
			alert("The entered post code is outside the area we can deliver to.");
			document.custinfo_form.delivery_area.value = "";
			document.custinfo_form.preferred_delivery_date.value = "";
			return false;	
		}		
		return true;
	}
	
	function CheckNSWPostCodes(nPostCode)
	{
		//Central Coast
		if (nPostCode < 2266 && nPostCode > 2249)
		{
			document.custinfo_form.delivery_area.value = LOCAL_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = LOCAL_DELIVERY_TIME;
		}
		//Canberra
		/*else if( (nPostCode > 2599 && nPostCode < 2621) ||
						 (nPostCode > 2899 && nPostCode < 2915))
		{
			document.custinfo_form.delivery_area.value = ACT_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = ACT_DELIVERY_TIME;
		}*/
		//Coffs Harbour, Northern Rivers
		/*else if (	(nPostCode > 2449 && nPostCode < 2453) || 
							(nPostCode > 2454 && nPostCode < 2457) || 
							(nPostCode == 2483) || 
							(nPostCode == 2485) || 
							(nPostCode == 2487))
		{
			document.custinfo_form.delivery_area.value = NRTH_NSW_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = NRTH_NSW_DELIVERY_TIME;
		}*/
		//Port Macquarie
		/*else if (nPostCode == 2444)
		{
			document.custinfo_form.delivery_area.value = PORT_MAC_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = PORT_MAC_DELIVERY_TIME;
		}*/
		//Sydney Metro, Wollongong, Newcastle
		/*else if( 	(nPostCode > 1999 && nPostCode < 2191) || 
							(nPostCode > 2210 && nPostCode < 2328) || 
							(nPostCode > 2332 && nPostCode < 2337) || 
							(nPostCode > 2499 && nPostCode < 2542) || 
							(nPostCode > 2554 && nPostCode < 2578) || 
							(nPostCode > 2744 && nPostCode < 2787) || 
							(nPostCode == 2790))
		{
			document.custinfo_form.delivery_area.value = SYDNEY_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = SYDNEY_DELIVERY_TIME;
		}*/
		//Albury, Wagga Wagga
		/*else if ((nPostCode == 2640) || (nPostCode == 2650))
		{
			document.custinfo_form.delivery_area.value = SOTH_NSW_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = SOTH_NSW_DELIVERY_TIME;
		}*/
		else
		{
			alert("The entered post code is outside the area we can deliver to.");
			document.custinfo_form.delivery_area.value = "";
			document.custinfo_form.preferred_delivery_date.value = "";
			return false;	
		}
	}
	
	function CheckQLDPostCodes(nPostCode)
	{
		//Brisbane
		if (nPostCode > 3999 && nPostCode < 4005)
		{
			document.custinfo_form.delivery_area.value = QLD_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = QLD_DELIVERY_TIME;
		}
		//Gold Coast
		else if ((nPostCode > 4209 && nPostCode < 4231) || (nPostCode > 4269 && nPostCode < 4276))
		{
			document.custinfo_form.delivery_area.value = QLD_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = QLD_DELIVERY_TIME;
		}
		//NorthGate Center
		else if (nPostCode > 4506 && nPostCode < 4512)
		{
			document.custinfo_form.delivery_area.value = QLD_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = QLD_DELIVERY_TIME;
		}
		//NorthGate Forward
		else if ((nPostCode > 4555 && nPostCode < 4561) || (nPostCode > 4565 && nPostCode < 4568) || (nPostCode > 4571 && nPostCode < 4574) || (nPostCode == 4564) || (nPostCode == 4575))
		{
			document.custinfo_form.delivery_area.value = QLD_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = QLD_DELIVERY_TIME;
		}
		//NorthGate North
		else if ((nPostCode > 4011 && nPostCode < 4015) || (nPostCode > 4031 && nPostCode < 4038) || (nPostCode > 4050 && nPostCode < 4066) || (nPostCode > 4499 && nPostCode < 4510))
		{
			document.custinfo_form.delivery_area.value = QLD_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = QLD_DELIVERY_TIME;
		}
		//Toowoomba
		else if ((nPostCode > 4299 && nPostCode < 4306) || (nPostCode > 4357 && nPostCode < 4366) || (nPostCode == 4342) || (nPostCode == 4345) || (nPostCode == 4347) || (nPostCode == 4354) || (nPostCode == 4356))
		{
			document.custinfo_form.delivery_area.value = QLD_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = QLD_DELIVERY_TIME;
		}
		//Widebay, Capricorn Coast, Mackay
		else if ((nPostCode > 4739 && nPostCode < 4743))
		{
			document.custinfo_form.delivery_area.value = NRTH_QLD_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = NRTH_QLD_DELIVERY_TIME;
		}
		else
		{
			alert("The entered post code is outside the area we can deliver to.");
			document.custinfo_form.delivery_area.value = "";
			document.custinfo_form.preferred_delivery_date.value = "";
			return false;	
		}
	}
	
	function CheckVICPostCodes(nPostCode)
	{
		//Victoria
		if (nPostCode > 2999 && nPostCode < 3095)
		{
			document.custinfo_form.delivery_area.value = VIC_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = VIC_DELIVERY_TIME;
		}
		
		else if ((nPostCode > 3100 && nPostCode < 3152) || (nPostCode > 3171 && nPostCode < 3208))
		{
			document.custinfo_form.delivery_area.value = VIC_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = VIC_DELIVERY_TIME;
		}
		
		else if (nPostCode > 3211 && nPostCode < 3229)
		{
			document.custinfo_form.delivery_area.value = VIC_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = VIC_DELIVERY_TIME;
		}
		
		else if ((nPostCode > 3239 && nPostCode < 3244) || (nPostCode > 3628 && nPostCode < 3633) || (nPostCode > 3688 && nPostCode < 3691) || (nPostCode == 3250) || (nPostCode == 3335))
		{
			document.custinfo_form.delivery_area.value = VIC_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = VIC_DELIVERY_TIME;
		}
		
		else if ((nPostCode > 3549 && nPostCode < 3557) || (nPostCode > 3751 && nPostCode < 3766) || (nPostCode > 3801 && nPostCode < 3930) || (nPostCode > 3930 && nPostCode < 3940))
		{
			document.custinfo_form.delivery_area.value = VIC_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = VIC_DELIVERY_TIME;
		}
		
		else if ((nPostCode > 3974 && nPostCode < 3978) || (nPostCode == 3944))
		{
			document.custinfo_form.delivery_area.value = VIC_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = VIC_DELIVERY_TIME;
		}
		else
		{
			alert("The entered post code is outside the area we can deliver to.");
			document.custinfo_form.delivery_area.value = "";
			document.custinfo_form.preferred_delivery_date.value = "";
			return false;	
		}	
	}
	
	function CheckSAPostCodes(nPostCode)
	{
		//Adelaide & Mt Gambier
		if ((nPostCode > 4999 && nPostCode < 5128) || (nPostCode > 5157 && nPostCode < 5172) || (nPostCode > 5172 && nPostCode < 5175))
		{
			document.custinfo_form.delivery_area.value = SA_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = SA_DELIVERY_TIME;
		}		
		else if ((nPostCode > 5271 && nPostCode < 5278) || (nPostCode > 5278 && nPostCode < 5292) || (nPostCode == 5349) || (nPostCode == 5355) || (nPostCode == 5360))
		{
			document.custinfo_form.delivery_area.value = SA_COST_DESCRIPTION;
			document.custinfo_form.preferred_delivery_date.value = SA_DELIVERY_TIME;
		}
		else
		{
			alert("The entered post code is outside the area we can deliver to.");
			document.custinfo_form.delivery_area.value = "";
			document.custinfo_form.preferred_delivery_date.value = "";
			return false;	
		}	
	}
	
	
	var slideShowArray = new Array();
	var Count=0;
	
	// Slideshow images
	slideShowArray[0] = "<A HREF=\"http://www.toosweettoeat.com.au/index.php?productID=122\"><IMG SRC=\"http://www.toosweettoeat.com.au/products_pictures/FlowersWithFlavour_medium.jpg\" border=\"0\" width=\"309\" height=\"290\" alt=\"Too Sweet To Eat::Chocolate Bouquets|Confectionery Arrangements\"></A>";
	
	
	function runSlideshow() 
	{
		oDiv.filters[0].Apply();
		
		if(Count > slideShowArray.length-1)
		{
			Count=0;
		}
		
		//Internet Explorer 
		document.getElementById('oDiv').innerHTML=slideShowArray[Count];		
		oDiv.filters[0].Play();
		
		setTimeout("runSlideshow()", 4000);
		Count++;
	}
