function calculateTotal(quantity1, quantity2, price1, price2, price3, id, product_name){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","getprice.cfm?quantity="+escape(document.getElementById('quantity'+id).value)+"&quantity1="+quantity1+"&quantity2="+quantity2+"&price1="+price1+"&price2="+price2+"&price3="+price3+"&id="+id+"&product_name="+product_name+thetime,false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
		var res = document.getElementById("temptot"+id);
		res.innerHTML = liveSearchReq.responseText;
	}
}

function updateQuantity(id){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","updateQuantity.cfm?id="+id+"&updatedQuantity="+escape(document.getElementById('updatedQuantity'+id).value)+"&posn="+escape(document.getElementById('posn'+id).value)+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		document.location.reload();
	}
}

function changeCountry(id){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","changeCountry.cfm?id="+id+"&delivery_country="+document.forms.theform.delivery_country.value+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		document.location.reload();
	}
}

function showHide(targetName) {
	if( document.getElementById ) { // NS6+
		target = document.getElementById(targetName);
	} else if( document.all ) { // IE4+
		target = document.all[targetName];
	}
	
	if( target ) {
		if( target.style.display == "none" ) {
			target.style.display = "inline";
		} else {
			target.style.display = "none";
		}
	}
} 

function showsecurityinfo(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	liveSearchReq.open("GET","securityinfo.html",false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("securityinfo");
		res.innerHTML = liveSearchReq.responseText;
	}
}

function getcarddetails(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	liveSearchReq.open("GET","carddetails.html",false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("entercarddetails");
		res.innerHTML = liveSearchReq.responseText;
	}
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}


function selectshipping(areavar){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	liveSearchReq.open("GET","workshipping.html?vararea="+areavar,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("thebutton");
		res.innerHTML = liveSearchReq.responseText;
	}
}

function emailOrder(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var thetime= "&thetime="+new Date().getTime();
	liveSearchReq.open("GET","emailOrder.cfm?formtitle="+document.forms.theform.title.value+"&formFirstname="+document.forms.theform.Firstname.value+"&formSurname="+document.forms.theform.Surname.value+"&formAddress1="+document.forms.theform.Address1.value+"&formAddress2="+document.forms.theform.Address2.value+"&formTown="+document.forms.theform.Town.value+"&formPostcode="+document.forms.theform.Postcode.value+thetime,false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
	document.location.reload();
	}
}

// Check card details have been entered
function isempty() {
	if (document.forms.theform.sameaddy.value == "no"){
		if (document.forms.theform.bill_firstname.value == "") {
			alert('You have not entered your Firstname')
			document.forms.theform.bill_firstname.focus()
			document.forms.theform.bill_firstname.select()
			var dosubmit = 'no'
			return false
		}
		if (document.forms.theform.bill_surname.value == "") {
			alert('You have not entered your Surname')
			document.forms.theform.bill_surname.focus()
			document.forms.theform.bill_surname.select()
			var dosubmit = 'no'
			return false
		}
		if (document.forms.theform.bill_add1.value == "") {
			alert('You have not entered your Address')
			document.forms.theform.bill_add1.focus()
			document.forms.theform.bill_add1.select()
			var dosubmit = 'no'
			return false
		}
		if (document.forms.theform.bill_postcode.value == "") {
			alert('You have not entered your Postcode')
			document.forms.theform.bill_postcode.focus()
			document.forms.theform.bill_postcode.select()
			var dosubmit = 'no'
			return false
		}
		if (document.forms.theform.bill_town.value == "") {
			alert('You have not entered your Town')
			document.forms.theform.bill_town.focus()
			document.forms.theform.bill_town.select()
			var dosubmit = 'no'
			return false
		}
	}
	if (document.forms.theform.name_on_card.value == "") {
		alert('You have not entered the name on your card')
		document.forms.theform.name_on_card.focus()
		document.forms.theform.name_on_card.select()
		var dosubmit = 'no'
		return false
	}
	if (document.forms.theform.card_num.value == "") {
		alert('You have not entered your Card number')
		document.forms.theform.card_num.focus()
		document.forms.theform.card_num.select()
		var dosubmit = 'no'
		return false
	}  
	if (document.forms.theform.expiry_month.value == "") {
		alert('You have not entered your expiry date correctly')
		document.forms.theform.expiry_month.focus()
		document.forms.theform.expiry_month.select()
		var dosubmit = 'no'
		return false
	}
	if (document.forms.theform.expiry_year.value == "") {
		alert('You have not entered your expiry date correctly')
		document.forms.theform.expiry_year.focus()
		document.forms.theform.expiry_year.select()
		var dosubmit = 'no'
		return false
	}
	if (document.forms.theform.cvv2.value == "") {
		alert('You have not entered the CVV2 Security Number')
		document.forms.theform.cvv2.focus()
		document.forms.theform.cvv2.select()
		var dosubmit = 'no'
		return false
	}
	
	
	if (dosubmit == 'no') {
	} else {
		document.forms.theform.submit();
	}
}

function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
        return false
    }
    status = ""
    return true
}

function show3Dmessage() {
window.open( "3dmessage.html", "3Dmessage", "status = 1, height = 300, width = 500, resizable = 0" )
}
