// JavaScript Document

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function UpCost() { 

// set up writable ids
	var buyform = document.getElementById("buyform");
	var disKwood = document.getElementById("kwood");
	var disKsize = document.getElementById("ksize");
	var disKstain = document.getElementById("kstain");
	var disKchew = document.getElementById("kchew");
	var disKlocks = document.getElementById("klocks");
	var disKbolts = document.getElementById("kbolts");
	var disKerect = document.getElementById("kerected");
	var disKdeliver = document.getElementById("kdeliver");
	var disUcost = document.getElementById("ucost");
	var disTcost = document.getElementById("tcost");

	var tcost = 0;
	var ucost = 0;
	var excost = 0;
	var stain = 0;
	var erect = 0;

// check size
	var size=buyform.size.value;
	if (size=="8x4") { excost = 435; stain = 35; erect = 55; } else 
	if (size=="10x4") { excost = 495; stain = 45; erect = 65; } else 
	if (size=="12x4") { excost = 545; stain = 50; erect = 75; } else 
	if (size=="14x4") { excost = 595; stain = 55; erect = 85; } else 
	if (size=="16x4") { excost = 645; stain = 65; erect = 95; } else 
	if (size=="20x4") { excost = 875; stain = 80; erect = 110; } else 
	if (size=="10x6") { excost = 575; stain = 55; erect = 80; } else 
	if (size=="12x6") { excost = 625; stain = 60; erect = 85; } else 
	if (size=="14x6") { excost = 685; stain = 65; erect = 90; } else 
	if (size=="16x6") { excost = 745; stain = 75; erect = 95; } else 
	if (size=="20x6") { excost = 985; stain = 95; erect = 125; }
	disKsize.firstChild.nodeValue = excost; // write size cost
	tcost += excost;

// check treatment cost
	if (buyform.stain.checked) { excost = stain; tcost += excost; } else
	{ excost = 0; }
	disKstain.firstChild.nodeValue = excost; // write staining cost

// check preservative cost
	excost=parseInt(buyform.woodp.value, 10);
	tcost += excost;
	disKwood.firstChild.nodeValue = excost; // write preservative cost

// check chew strips cost
	if (buyform.chew.checked)
	{ excost = 10; } else { excost = 0;}
	disKchew.firstChild.nodeValue = excost; // write chew cost
	tcost += excost;
	
// check locks cost
	if (buyform.locks.checked)
	{ excost = 10; } else { excost = 0; }
	disKlocks.firstChild.nodeValue = excost; // write locks cost
	tcost += excost;

// check bolts cost
	if (buyform.bolts.checked)
	{ excost = 5; } else { excost = 0; }
	disKbolts.firstChild.nodeValue = excost; // write bolts cost
	tcost += excost;

// check erected
	if (buyform.erected.checked) {
	excost = erect;
	tcost += excost; } else {
	excost = 0; }
	disKerect.firstChild.nodeValue = excost; // write erection cost

// set unit cost
	ucost = tcost.toFixed(2);

// check delivery cost
	del=parseInt(buyform.deliver.value, 10);
//	var del=buyform.delivery.value;
//	if ((del == "PE Postcode") || (del == "No Delivery")) { excost = 0;} else
//	if (del == "East Anglia") { excost = 20;} else
//	if (del == "Scotland") { excost = 80;} else
//	if (del == "Wales") { excost = 50; }
//	disKdeliver.firstChild.nodeValue = excost; // write delivery cost
//	tcost += excost;
	excost = del;
//	alert("delivery=" +excost);
	disKdeliver.firstChild.nodeValue = excost; // write delivery cost
//	excost = excost.toFixed(2);
	tcost += excost;
	tcost = tcost.toFixed(2);

// display unit cost
	disUcost.innerHTML = ucost; // write unit cost
//	disTcost.innerHTML = tcost; // write unit cost
	disTcost.firstChild.nodeValue = tcost; // write unit cost
//	buyform.utotal.value = ucost; // write unit variable
	buyform.ttotal.value = tcost; // write unit variable

}

Number.prototype.toFix = function(places){
  var temp = ( Math.round( this * Math.pow(10,places) ) ).toString();
  return temp.substring(0,temp.length-places) + "." + temp.substring(temp.length-places, temp.length);
}

function CheckAll() { //check lens and colour selected and e-mail entered
if(document.buyform.colour.selectedIndex == "") {
 alert("Please select Frame Colour");
 return false; }
if(document.buyform.lens.selectedIndex == "") {
 alert("Please select Lens Type");
 return false; }
}


