function updateCart() {
	document.forms["cart"].action = document.getElementById("cartURL").value;
	document.forms["cart"].submit();
}

function submitCart() {
	/*
	var emailRegex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!emailRegex.test(document.forms["cart"].elements["email"].value)) {
		alert("Please enter a valid email address");
		return false;
	}
	*/
	document.forms["cart"].action = document.getElementById("paypalURL").value;
	document.forms["cart"].submit();
}

function showCheckout() {
	document.getElementById("checkout_1").style.display = null;
	document.getElementById("checkout_2").style.display = null;
	document.getElementById("checkout_3").style.display = null;
	document.getElementById("checkout_4").style.display = null;
	document.getElementById("checkout_5").style.display = null;
	document.getElementById("checkout_6").style.display = null;
	window.location = "#FormBottom";
}

function calculatePostage(amount) {
	var postage = parseFloat(amount);
	var subtotal = parseFloat(document.getElementById("subtotal").value);
	var total = postage + subtotal;
	document.getElementById("postageDisplay").innerHTML = postage;
	document.getElementById("totalDisplay").innerHTML = total;
	document.getElementById("shipping_1").value = postage;
}

function doPostage() {
	var numberOfItems = parseInt(document.getElementById("NumberOfItems").value);
	var country = document.getElementById("country").value;
	var totalAmount = 0;
	var totalPostage = 0;

	if(document.getElementById("postage["+country+"]")) {
		var postagePerItem = parseFloat(document.getElementById("postage["+country+"]").value);
	}
	else {
		var postagePerItem = parseFloat(document.getElementById("postage[DEFAULT]").value);
	}


	for(var i=1; i<(numberOfItems+1); i++) {

		document.forms["cart"].elements["shipping_"+i].value = postagePerItem;
		document.forms["cart"].elements["shipping2_"+i].value = postagePerItem;

		var thisAmount = parseFloat(document.forms["cart"].elements["amount_"+i].value);
		thisAmount+= postagePerItem;
		var thisQuant = parseInt(document.forms["cart"].elements["quantity_"+i].value);

		var thisPostage = (thisQuant*postagePerItem);
		var thisTotal = (thisQuant*thisAmount);

		totalPostage+= thisPostage;
		totalAmount+= thisTotal;
	}

	document.getElementById("PostageAmount").innerHTML = "US&nbsp;$"+totalPostage;
	document.getElementById("TotalAmount").innerHTML = "US&nbsp;<strong>$"+totalAmount+"</strong>";
	document.forms["cart"].elements["amount"].value = totalAmount;

}