var price_ak = new
Array(169.90,113.16,127.31,125.93,55.78,60.61,53.07,181.13,155.25,199.81,175.95,217.35,240.35,204.30,233.62,253.17,155.25,199.81,99.94,218.50,218.50);
var price_ni = new Array(169.90,138.69,150.42,148.18,79.47,84.30,75.90,232.88,199.81,248.69,228.85,274.85,297.85,253.17,282.50,302.05,199.81,248.69,110.75,242.94,242.94);
var price_si = new Array(169.90,161.86,175.61,172.90,106.03,110.86,101.26,301.88,257.31,306.19,274.85,320.85,343.85,292.27,321.60,350.92,257.31,306.19,127.82,280.31,280.31);
var surface  = new Array(0.0,16.94,22.58,36.16,28.40,29.69,36.16,7.01,11.58,13.78,15.46,18.05,19.34,19.34,21.28,23.22,11.58,13.78,12.61,12.61,12.61);
var volume  = new Array(0.00,0.30,0.30,0.30,0.30,0.30,0.60,0.60,0.60,0.60,0.60,0.60,0.60,0.60,0.60,0.60,0.45,0.45,0.30,0.30);
var rate = new Array(0.00,84.37,95.63,106.88);
var price = new Array();
var Location;

function SetPage() {
	var i = 0;
	Location = document.orderForm.Location.value;
	if ((Location == 0) || (Location == 9)) {
		price = price_ak;
	}
	else if  (Location==1) {
		price = price_ni;
	}
	else {
		price = price_si;
	}
	if (document.getElementById) {
		document.getElementById("f1a").innerHTML = price[i].toFixed(2);
		i++;
		document.getElementById("f2a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f3a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f4a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f5a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f6a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f7a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f8a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f9a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f10a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f11a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f12a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f13a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f14a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f15a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f16a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f17a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f18a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f19a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f20a").innerHTML = price[i].toFixed(2);	
		i++;
		document.getElementById("f21a").innerHTML = price[i].toFixed(2);	
		i++;
	}
}

function reCalc() {
	var qty;
	var total = 0;
	var units = 0;
	var width = -1;
	var goods ='';
	var i =0;
	var frt = document.orderForm.area.value;
	var freight = rate[frt];
	Location = document.orderForm.Location.value;
	if ((Location == 0) || (Location == 9)) {
		price = price_ak;
	}
	else if (Location==1) {
		price = price_ni;
	}
	else {
		price = price_si;
	}
	if (document.orderForm.aueco.value >0) {
		qty = document.orderForm.aueco.value *1;
		total += qty * price[i];
		units += qty;
		goods += "aueco:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au20w.value >0) {
		qty = document.orderForm.au20w.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au20w:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au22w.value >0) {
		qty = document.orderForm.au22w.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au22w:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au25w.value >0) {
		qty = document.orderForm.au25w.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au25w:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au29c.value >0) {
		qty = document.orderForm.au29c.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au29c:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au32c.value >0) {
		qty = document.orderForm.au32c.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au32c:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au34c.value >0 ) {
		qty = document.orderForm.au34c.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au34c:" + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au10r.value >0) {
		qty = document.orderForm.au10r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a10r.value *1;
		goods += "au10r:" + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au15r.value >0) {
		qty = document.orderForm.au15r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a15r.value *1;
		goods += "au15r:" + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au18r.value >0) {
		qty = document.orderForm.au18r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a18r.value *1;
		goods += "au18r:" + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au22r.value >0) {
		qty = document.orderForm.au22r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a22r.value *1;
		goods += "au22r:"  + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au24r.value >0) {
		qty = document.orderForm.au24r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a24r.value *1;
		goods += "au24r:" + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au26r.value >0) {
		qty = document.orderForm.au26r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a26r.value *1;
		goods += "au26r:" + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au29r.value >0) {
		qty = document.orderForm.au29r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a29r.value *1;
		goods += "au29r:" + qty + ":"  + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au32r.value >0) {
		qty = document.orderForm.au32r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a32r.value *1;
		goods += "au32r:" + qty + ":" + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au34r.value >0) {
		qty = document.orderForm.au34r.value *1;
		total += qty * price[i];
		units += qty;
		width = document.orderForm.a34r.value *1;
		goods += "au34r:" + qty + ":" + width +"\t";
		width = -1;
	}
	i++;
	if (document.orderForm.au15u.value >0) {
		qty = document.orderForm.au15u.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au15u:" + qty + ":" + width +"\t";
	}
	i++;
	if (document.orderForm.au18u.value >0) {
		qty = document.orderForm.au18u.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au18u:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au58sp.value >0) {
		qty = document.orderForm.au58sp.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au58sp:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au43sr.value >0) {
		qty = document.orderForm.au43sr.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au43sr:" + qty + ":"  + width +"\t";
	}
	i++;
	if (document.orderForm.au58sr.value >0) {
		qty = document.orderForm.au58sr.value *1;
		total += qty * price[i];
		units += qty;
		goods += "au58sr:" + qty + ":"  + width +"\t";
	}
	// if total is over a value then we discount the product
	var discount = 0;
	if (total  > 4999.99) discount = total * 0.05;
	if ((total > 3999.99)&&(total < 5000.00)) discount = total * 0.025;
	if ((total > 1999.99)&&(total < 4000.00))  discount = total * 0.0125;
//	if (total > 1000) discount = total * 0.00625;

	var discounted = total - discount;
	if ((!isNaN(units)) && (!isNaN(total))) {
		var gst = discounted*15/100;
		var totle = discounted + gst + freight;
		document.orderForm.rate.value = goods;
		if (document.getElementById) {
			document.getElementById("GoodsTotal").innerHTML = total.toFixed(2);
			document.getElementById("DiscTotal").innerHTML = discount.toFixed(2);
			document.getElementById("SubTotal").innerHTML = discounted.toFixed(2);
			document.getElementById("GST").innerHTML = gst.toFixed(2);
			document.getElementById("Freight").innerHTML = freight.toFixed(2);
			document.getElementById("Total").innerHTML = totle.toFixed(2);
		}
	}
}
function CheckWidth() {
	var errorFlag = 0;
	if (document.orderForm.au10r.value >0) {
		if ((document.orderForm.a10r.value<300) || (document.orderForm.a10r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au15r.value >0) {
		if ((document.orderForm.a15r.value<300) || (document.orderForm.a15r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au18r.value >0) {
		if ((document.orderForm.a18r.value<300) || (document.orderForm.a18r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au22r.value >0) {
		if ((document.orderForm.a22r.value<300) || (document.orderForm.a22r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au24r.value >0) {
		if ((document.orderForm.a24r.value<300) || (document.orderForm.a24r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au26r.value >0) {
		if ((document.orderForm.a26r.value<300) || (document.orderForm.a26r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au29r.value >0) {
		if ((document.orderForm.a29r.value<300) || (document.orderForm.a29r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au32r.value >0) {
		if ((document.orderForm.a32r.value<300) || (document.orderForm.a32r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (document.orderForm.au34r.value >0) {
		if ((document.orderForm.a34r.value<300) || (document.orderForm.a34r.value>1200)) {
			errorFlag = 1;
		}
	}
	if (errorFlag) {
		alert("The width of Custom Made Products must be between 300mm and 1200mm.");
		return false;
	}
	if (!document.orderForm.first_name.value) errorFlag = 1;
	if (!document.orderForm.last_name.value)  errorFlag = 1;
	if (!document.orderForm.delivery_street.value) errorFlag = 1;
	if (!document.orderForm.delivery_town.value) errorFlag = 1;
	if (!document.orderForm.delivery_city.value) errorFlag = 1;
	if (!document.orderForm.nemail.value)     errorFlag = 1;
	if (!document.orderForm.phone.value)      errorFlag = 1;
	if (errorFlag) {
		alert("Your delivery instructions must be completed before proceeding.");
		return false;
	}
	return true;
}

