<!-- hide from old browsers

var days = new Array();
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";

var months = new Array();
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";

function changeSize(theclass) {
	
	bottlecolour = document.getElementById('BottleColourCode').value;
	strapcode = document.getElementById('StrapColourCode').value;
		
	if (theclass==2 && (bottlecolour=="red" || bottlecolour=="silver")) {
		alert("Temporarily out of stock of red and silver 750ml bottles");
	}else{
		document.getElementById('BottleSizeID').value=theclass;
		document.getElementById('bottle_body').className="body_" + theclass + "_" + bottlecolour;
		document.getElementById('bottle_strap').className="strap_" + theclass + "_" + strapcode;
	}
	return false;
}

function changeBody(theclass) {
	
	bottlesize = document.getElementById('BottleSizeID').value;
	if (bottlesize==2 && (theclass=="red" || theclass=="silver")) {
		alert("Temporarily out of stock of red and silver 750ml bottles");
	}else{
		document.getElementById('BottleColourCode').value=theclass;
		document.getElementById('bottle_body').className="body_" + bottlesize + "_" + theclass;
	}
	return false;
}


function changeLid(theclass) {
	lidstyle = document.getElementById('LidStyleCode').value;
	if ((theclass=='white' || theclass=='silver') && lidstyle=='valve') {
		theclass='cyan';
		alert("Sorry, this lid-style / colour combination is not available\n This has now been set to cyan.");
	}
	if ((theclass=='yellow' || theclass=='green') && lidstyle=='pushpull') {
		theclass='cyan';
		alert("Sorry, this lid-style / colour combination is not available\n This has now been set to cyan.");
	}
	if ((theclass=='clear' || theclass=='red') && lidstyle=='pushpull') {
		theclass='cyan';
		alert("Sorry, the clear and red push-pull caps are temporarily out of stock\nThis has now been set to cyan.");		
	}
	document.getElementById('LidColourCode').value=theclass;
	document.getElementById('bottle_lid').className="lid_" + lidstyle + "_" + theclass;
	return false;
}

function changeCap(theclass) {

	var div1 = document.getElementById('step4');
	var div2 = document.getElementById('step4temp');
	

	lidcolour = document.getElementById('LidColourCode').value;
	if ((lidcolour=='white' || lidcolour=='silver') && theclass=='valve') {
		lidcolour='cyan';
		document.getElementById('LidColourCode').value = lidcolour;
		alert("Sorry, this lid-style / colour combination is not available\n This has now been set to cyan.");
	}
	if ((lidcolour=='yellow' || lidcolour=='green') && theclass=='pushpull') {
		lidcolour='cyan';
		document.getElementById('LidColourCode').value = lidcolour;
		alert("Sorry, this lid-style / colour combination is not available\n This has now been set to cyan.");
	}
	if ((lidcolour=='clear' || lidcolour=='red') && theclass=='pushpull') {
		lidcolour='cyan';
		document.getElementById('LidColourCode').value = lidcolour;
		alert("Sorry, the clear and red push-pull caps are temporarily out of stock\nThis has now been set to cyan.");		
	}
	document.getElementById('LidStyleCode').value=theclass;
	document.getElementById('bottle_lid').className="lid_" + theclass + "_" + lidcolour;
	
	if (theclass==div1.getAttribute('rel')) {
	}else{
		div1.id="step4temp";
		div2.id="step4";
	}

	return false;
}

function changeOvercap(theclass) {
	lidstyle = document.getElementById('LidStyleCode').value;
	if (lidstyle=="valve") {
		alert("Sorry, the overcap is not available for the hands-free cap.");
	}else{

	document.getElementById('OvercapColourCode').value=theclass;
	document.getElementById('bottle_overcap').className="overcap_" + theclass;
	}
	return false;
}

function changeStrap(theclass) {
	bottlesize = document.getElementById('BottleSizeID').value;
	if (theclass=='yes') {
		alert("Sorry this item is temporarily out of stock - please contact us for an update");
	}
	//document.getElementById('StrapColourCode').value=theclass;
	//document.getElementById('bottle_strap').className="strap_" + bottlesize + "_" + theclass;
	return false;
}

function changeNameBody(theclass) {
	document.getElementById('BottleColourCode').value = theclass;
	document.getElementById('bottle_body').className = 'namebody_' +theclass;
	return false;	
}

function changeNameLid(theclass) {
	lidstyle = document.getElementById('LidStyleCode').value;
	if ((theclass=='white' || theclass=='silver') && lidstyle=='valve') {
		theclass = 'cyan'
		alert("Sorry, this lid-style / colour combination is not available\nThis has now been set to cyan.");
	}
	if ((theclass=='yellow' || theclass=='green') && lidstyle=='pushpull') {
		theclass = 'cyan'
		alert("Sorry, this lid-style / colour combination is not available\nThis has now been set to cyan.");
	}
	if ((theclass=='clear' || theclass=='red') && lidstyle=='pushpull') {
		theclass = 'cyan'
		alert("Sorry, the clear and red push-pull caps are temporarily out of stock\nThis has now been set to cyan.");
	}
	document.getElementById('LidColourCode').value=theclass;
	document.getElementById('bottle_lid').className="namelid_" + lidstyle + "_" + theclass;
	return false;
}

function changeNameCap(theclass) {
	lidcolour = document.getElementById('LidColourCode').value;
	
	var div3 = document.getElementById('step2');
	var div4 = document.getElementById('step2temp');
	
	if (div3.getAttribute('rel') == "valve" || div3.getAttribute('rel') == "pushpull") {
		if (theclass==div3.getAttribute('rel')) {
		}else{
			div3.id="step2temp";
			div4.id="step2";
			
			document.getElementById('step2').style.display = "block";
			document.getElementById('step2temp').style.display = "none";
		}
	}
	
	if ((lidcolour=='white' || lidcolour=='silver') && theclass=='valve') {
		lidcolour = 'cyan';
		document.getElementById('LidColourCode').value = lidcolour;
		alert("Sorry, this lid-style / colour combination is not available\nThis has now been set to cyan.");
	}
	if ((lidcolour=='yellow' || lidcolour=='green') && theclass=='pushpull') {
		lidcolour = 'cyan';
		document.getElementById('LidColourCode').value = lidcolour;
		alert("Sorry, this lid-style / colour combination is not available\nThis has now been set to cyan.");
	}
	if ((lidcolour=='clear' || lidcolour=='red') && theclass=='pushpull') {
		lidcolour = 'cyan';
		document.getElementById('LidColourCode').value = lidcolour;
		alert("Sorry, the clear and red push-pull caps are temporarily out of stock\nThis has now been set to cyan.");	
	}
	document.getElementById('LidStyleCode').value=theclass;
	document.getElementById('bottle_lid').className="namelid_" + theclass + "_" + lidcolour;
	return false;
}

function changeNameOvercap(theclass) {
	document.getElementById('OvercapColourCode').value=theclass;
	document.getElementById('bottle_overcap').className="nameovercap_" + theclass;
	return false;
}

function changeNameStrap(theclass) {
	document.getElementById('StrapColourCode').value=theclass;
	document.getElementById('bottle_strap').className="namestrap_" + theclass;
	return false;
}

function toggleDiv(turnon,turnoff) {
	splitOnVals = turnon.split(",");
	splitOffVals = turnoff.split(",");
	for(i=0; i<(splitOnVals.length); i++) {
		document.getElementById(splitOnVals[i]).style.display="block";
	}
	for(i=0; i<(splitOffVals.length); i++) {
		document.getElementById(splitOffVals[i]).style.display="none";
	}
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function calculatePrice() {
	var xmlhttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	@end @*/

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	var returnText;
	
	var BottleSizeID = document.getElementById('BottleSizeID').value;
	var BottleColourCode = document.getElementById('BottleColourCode').value;
	var LidColourCode = document.getElementById('LidColourCode').value;
	var LidStyleCode = document.getElementById('LidStyleCode').value;
	var OvercapColourCode = document.getElementById('OvercapColourCode').value;
	var StrapColourCode = document.getElementById('StrapColourCode').value;
	var optionqty = document.getElementById('optionqty').value;
	var optioncolours = getCheckedValue(document.forms['ProdForm'].elements['optioncolours']);
	if (optioncolours == "") {optioncolours = document.getElementById('optioncolours').value};
	var carriersqty = document.getElementById('carriersqty').value;
	if (document.getElementById('shipcountry')){
		var delcountry = document.getElementById('shipcountry').value;
	}
	
		if (optionqty<100) {
			document.getElementById('optionqty').value = 100;
			alert("Mininum quantity is 100");
			return false;
		}
		
		if (carriersqty<10 && carriersqty>0) {
			document.getElementById('carriersqty').value = 0;
			alert("Mininum quantity is 10");
			return false;
		}

	uri = "/x_calculate.asp?BottleSizeID=" + BottleSizeID + "&optionqty=" + optionqty +  "&optioncolours=" + optioncolours + "&OvercapColourCode=" + OvercapColourCode + "&StrapColourCode=" + StrapColourCode + "&carriersqty=" +  carriersqty + "&delcountry=" + delcountry;

	xmlhttp.open("GET", uri ,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			returnText = xmlhttp.responseText;

			document.getElementById('theprice').innerHTML = '';
			if (returnText == "EOF") {
				newText = "All Types";
			} else {
				newText = returnText;
			}


			document.getElementById('theprice').innerHTML = newText;

		}
	}

	xmlhttp.send(null);
	return false;

}

function calculatePrice2() {
	var xmlhttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
		}
	}
	@end @*/

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}

	var returnText;
	
	var BottleColourCode = document.getElementById('BottleColourCode').value;
	var LidColourCode = document.getElementById('LidColourCode').value;
	var LidStyleCode = document.getElementById('LidStyleCode').value;
	var optionqty = document.getElementById('optionqty').value;
	var carriersqty = document.getElementById('carriersqty').value;
	if (document.getElementById('shipcountry')){
		var delcountry = document.getElementById('shipcountry').value;
	}
	
		if (optionqty<1) {
			document.getElementById('optionqty').value = 1;
			alert("Mininum quantity is 1");
			return false;
		}
		
		if (carriersqty<10 && carriersqty>0) {
			document.getElementById('carriersqty').value = 0;
			alert("Mininum quantity is 10");
			return false;
		}
		
	uri = "/x_calculate2.asp?optionqty=" + optionqty + "&carriersqty=" +  carriersqty + "&delcountry=" + delcountry;;

	xmlhttp.open("GET", uri ,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			returnText = xmlhttp.responseText;

			document.getElementById('theprice').innerHTML = '';
			if (returnText == "EOF") {
				newText = "All Types";
			} else {
				newText = returnText;
			}


			document.getElementById('theprice').innerHTML = newText;

		}
	}

	xmlhttp.send(null);
	return false;

}



function validateForm() {
	thereturn=true;
	if (document.getElementById('shipfirstname').value=="") {
		document.getElementById('shipfirstname').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('shipsurname').value=="") {
		document.getElementById('shipsurname').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('shipaddress1').value=="") {
		document.getElementById('shipaddress1').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('shiptown').value=="") {
		document.getElementById('shiptown').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('shippostcode').value=="") {
		document.getElementById('shippostcode').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('firstname').value=="") {
		document.getElementById('firstname').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('surname').value=="") {
		document.getElementById('surname').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('address1').value=="") {
		document.getElementById('address1').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('town').value=="") {
		document.getElementById('town').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('postcode').value=="") {
		document.getElementById('postcode').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('email').value=="") {
		document.getElementById('email').style.background="#ff0000";
		thereturn=false;
	}
	if (document.getElementById('telephone').value=="") {
		document.getElementById('telephone').style.background="#ff0000";
		thereturn=false;
	}
	if (thereturn==false) {
		alert("You must complete all required fields.")
	}
	return thereturn;
}

function copyAddress() {
	if (document.getElementById('usebilling').checked) {
		document.getElementById('shipfirstname').value = document.getElementById('firstname').value;
		document.getElementById('shipsurname').value = document.getElementById('surname').value;
		document.getElementById('shipaddress1').value = document.getElementById('address1').value;
		document.getElementById('shipaddress2').value = document.getElementById('address2').value;
		document.getElementById('shipaddress3').value = document.getElementById('address3').value;
		document.getElementById('shiptown').value = document.getElementById('town').value;
		document.getElementById('shipcounty').value = document.getElementById('county').value;
		document.getElementById('shippostcode').value = document.getElementById('postcode').value;
		document.getElementById('shipcountry').value = document.getElementById('country').value;
		document.getElementById('shiptelephone').value = document.getElementById('telephone').value;
	}else{
		document.getElementById('shipfirstname').value = "";
		document.getElementById('shipsurname').value = "";
		document.getElementById('shipaddress1').value = "";
		document.getElementById('shipaddress2').value = "";
		document.getElementById('shipaddress3').value = "";
		document.getElementById('shiptown').value = "";
		document.getElementById('shipcounty').value = "";
		document.getElementById('shippostcode').value = "";
		document.getElementById('shipcountry').value = "UK";
		document.getElementById('shiptelephone').value = "";
	}
}

function checkEmail(strng) {
	var error = "";

	var emailFilter=/^.+@.+\..{2,6}$/;

	if (!(emailFilter.test(strng))) {
		return false;
	}

	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\] ']/

	if (strng.match(illegalChars)) {
		return false;
	}

	return true;
}

function formVal(thefields,theemails) {
	thereturn = true;
	theemailreturn = true
	
	fparts = thefields.split(",");
	for (i = 0; i < fparts.length; i++) {
		if (document.getElementById(fparts[i]).value=='') {
			document.getElementById(fparts[i]).style.background='#ff0000';
			thereturn = false;
		}else{
			document.getElementById(fparts[i]).style.background='#ffffff';
		}
	}
	if (thereturn==false) { alert('You must complete all required fields'); }
	
	
	if (theemails!='') {
	fparts = theemails.split(",");
	for (i = 0; i < fparts.length; i++) {
		if (checkEmail(document.getElementById(fparts[i]).value)==false) {
			document.getElementById(fparts[i]).style.background='#ff0000';
			theemailreturn = false;
			thereturn = false;
		}else{
			document.getElementById(fparts[i]).style.background='#ffffff';
		}
	}
	if (theemailreturn==false) { alert('You must enter a valid email address'); }
	}
	return thereturn;
}

// - end hiding -->