// Shipping charges for each country
 shippingcharges =new Array();

// uk     
uk = new Array();
	uk[1] = 4.00; 
	uk[2] = 6.00; 
	uk[3] = 9.00; 
	uk[4] = 12.00; 
	uk[5] = 15.00; 
	uk[6] = 25.00; 
	uk[7] = 25.00; 
	uk[8] = 25.00; 
	uk[9] = 25.00; 
	uk[10] = 25.00; 
   
// eu
eu = new Array();
	eu[1] = 5.00; 
	eu[2] = 10.00; 
	eu[3] = 15.00; 
	eu[4] = 20.00; 
	eu[5] = 25.00; 
	eu[6] = 35.00; 
	eu[7] = 35.00; 
	eu[8] = 35.00; 
	eu[9] = 35.00; 
	eu[10] = 35.00; 

// us
us = new Array();
	us[1] = 8.00; 
	us[2] = 16.00; 
	us[3] = 24.00; 
	us[4] = 32.00; 
	us[5] = 40.00; 
	us[6] = 60.00; 
	us[7] = 60.00; 
	us[8] = 60.00; 
	us[9] = 60.00; 
	us[10] = 60.00; 
	

shippingcharges = [uk,eu,us];

var unitPrice = 34.00;

function calculate () {
	var qty = $("#quantity").val();
	var region = $("#region").val();
	var shipping = shippingcharges[region][qty];
	
	var subtotal = eval(qty * unitPrice);
	var total = eval(subtotal+shipping);
	
	$("#subtotal").html("&pound;"+ subtotal+".00");
	$("#shipping_amount").html("&pound;"+shipping+".00");
	$("#total").html("&pound;"+ total+".00");
	
	// hidden fields
	$("#shipping").val(shipping);
	//$("#amount").val(subtotal);
}


$(document).ready(function(){
// reset everything 
		calculate();


$("#quantity").change(function () {
		calculate();
    	if (this.value != 10){
			
			
			$("#place_order").attr("disabled",""); 
			$("#message").remove();
		}
		else {
			//alert("too many!");
			$("#total").html("&mdash;");
			$("#place_order").attr("disabled","disabled"); 
			
			
			$(".submit").prepend("<span id=\"message\">You are ordering a lot of packs. Please call us on +44 7771771684 or <a href=\"mailto:robfox@engagingideas.co.uk\">email us</a>, and we can better arrange your purchase.<\/span>");
			}
		})
		
$("#region").change(function () {
	 	
	 	//if (this.value > 0){
		calculate()
		//}
	 })
		
});









