window.onerror = SymError;
function SymError() { return true; }

		orderSent=false;
		var del = "0"
		var discount ="0"
		var vatrate = "20"

dayName = new Array("Sun","Mon","Tues","Wed","Thurs","Fri","Sat")
monName = new Array("Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov","Dec")
now = new Date

function twoPlaces(amount) {
return (amount == Math.floor(amount)) ? amount+'.00' :
((amount*10 == Math.floor(amount*10)) ? amount+'0': amount);
}

function round(number,X) {
var X = "2";
return Math.round(number*Math.pow(10,X)) / Math.pow(10,X);
}

		function totals(num) {
	return twoPlaces(Math.floor((num - 0) * 100) / 100);
	}

				function addPrice() {
		var docor=document.workbench_order		      //form name

		docor.refno1.value = docor.refno1.value.toUpperCase();
		docor.refno2.value = docor.refno2.value.toUpperCase();
		docor.refno3.value = docor.refno3.value.toUpperCase();
		docor.refno4.value = docor.refno4.value.toUpperCase();
		docor.refno5.value = docor.refno5.value.toUpperCase();
		
		if (docor.refno1.value=="") {(docor.listp1.value="")+(docor.qty1.value="")}
		else {docor.listp1.value= prodPrice[docor.refno1.value];
		docor.desc1.value=prodDesc[docor.refno1.value]; }
		
		if (docor.refno1.value=="") {docor.desc1.value=""}
		
		if (docor.refno2.value=="") {(docor.listp2.value="")+(docor.qty2.value="")}
		else {docor.listp2.value= prodPrice[docor.refno2.value]
		docor.desc2.value=prodDesc[docor.refno2.value]; }
		
		if (docor.refno2.value=="") {docor.desc2.value=""}
		
		if (docor.refno3.value=="") {(docor.listp3.value="")+(docor.qty3.value="")}
		else {docor.listp3.value= prodPrice[docor.refno3.value];
		docor.desc3.value=prodDesc[docor.refno3.value]; }
		
		if (docor.refno3.value=="") {docor.desc3.value=""}
		
		if (docor.refno4.value=="") {(docor.listp4.value="")+(docor.qty4.value="")}
		else {docor.listp4.value= prodPrice[docor.refno4.value];
		docor.desc4.value=prodDesc[docor.refno4.value]; }
		
		if (docor.refno4.value=="") {docor.desc4.value=""}
		
		if (docor.refno5.value=="") {(docor.listp5.value="")+(docor.qty5.value="")}
		else {docor.listp5.value= prodPrice[docor.refno5.value];
		docor.desc5.value=prodDesc[docor.refno5.value]; }
		
		if (docor.refno5.value=="") {docor.desc5.value=""}

				if(docor.qty1.value==""){
		docor.tot1.value="0.00";}
		if(docor.qty2.value==""){
		docor.tot2.value="0.00";}
		if(docor.qty3.value==""){
		docor.tot3.value="0.00";}
		if(docor.qty4.value==""){
		docor.tot4.value="0.00";}
		if(docor.qty5.value==""){
		docor.tot5.value="0.00";}
		
		}

function add2Form(ref) {
		var docor=document.workbench_order      //form name
		var prodinfo=ref

if(confirm("The following product will be added to your order basket:\n"+prodinfo+"")){

		if(docor.refno1.value==""){(docor.refno1.focus())+(docor.refno1.value=ref)+(docor.qty1.value="1")+(docor.refno1.blur())+addPrice()+WorkitOut()+TotalitUp();}

		else
if(docor.refno2.value==""){(docor.refno2.focus())+(docor.refno2.value=ref)+(docor.qty2.value="1")+(docor.refno2.blur())+addPrice()+WorkitOut()+TotalitUp();}

		else
if(docor.refno3.value==""){(docor.refno3.focus())+(docor.refno3.value=ref)+(docor.qty3.value="1")+(docor.refno3.blur())+addPrice()+WorkitOut()+TotalitUp();}

		else
if(docor.refno4.value==""){(docor.refno4.focus())+(docor.refno4.value=ref)+(docor.qty4.value="1")+(docor.refno4.blur())+addPrice()+WorkitOut()+TotalitUp();}

		else
if(docor.refno5.value==""){(docor.refno5.focus())+(docor.refno5.value=ref)+(docor.qty5.value="1")+(docor.refno5.blur())+addPrice()+WorkitOut()+TotalitUp();}

		else

	alert("Your order form appears to be full.\nPlease SEND the current order form content,\nand then reuse the form for additional products.\nThank you")

		if (docor.refno2.value=="") {docor.desc2.value="";}
		if (docor.refno3.value=="") {docor.desc3.value="";}
		if (docor.refno4.value=="") {docor.desc4.value="";}
		if (docor.refno5.value=="") {docor.desc5.value="";}
		}
		
		function buildRef(){
		var docor=document.workbench_order      //form name
		(docor.workbenchref.value=docor.style.value+docor.size.value+docor.worktop.value);
		}
}
		
		function addtoForm() {
				var docor=document.workbench_order      //form name
if(docor.refno1.value=="")(docor.refno1.focus())+(docor.refno1.value=docor.workbenchref.value)+(docor.qty1.focus())+(docor.qty1.value="1")+(docor.qty1.blur())+addPrice()+WorkitOut()+TotalitUp();
		else
		if(docor.refno2.value=="")(docor.qty2.value="1")+(docor.refno2.value=docor.workbenchref.value)+addPrice()+WorkitOut()+TotalitUp();
		else
		if(docor.refno3.value=="")(docor.qty3.value="1")+(docor.refno3.value=docor.workbenchref.value)+addPrice()+WorkitOut()+TotalitUp();
		else
		if(docor.refno4.value=="")(docor.qty4.value="1")+(docor.refno4.value=docor.workbenchref.value)+addPrice()+WorkitOut()+TotalitUp();
		else
		if(docor.refno5.value=="")(docor.qty5.value="1")+(docor.refno5.value=docor.workbenchref.value)+addPrice()+WorkitOut()+TotalitUp();
		else
alert("Your order form appears to be full.\nPlease SEND the current order form content,\nand then reuse the form for additional products.\nThank you")
		}
		
		function WorkitOut() {
	var docor=document.workbench_order      //form name
	var div = Math.pow(10,2);
	
docor.tot1.value= twoPlaces(round((docor.qty1.value*docor.listp1.value)));

docor.tot2.value= twoPlaces(round(eval(docor.qty2.value*docor.listp2.value)));

docor.tot3.value= twoPlaces(round((docor.qty3.value*docor.listp3.value)));

docor.tot4.value= twoPlaces(round((docor.qty4.value*docor.listp4.value)));

docor.tot5.value= twoPlaces(round((docor.qty5.value*docor.listp5.value)));
		}
		



		function TotalitUp() {
		var docor=document.workbench_order      //form name
		var div = Math.pow(10,2);
		docor.deltotal.value= twoPlaces(round(del));

	docor.subtotal.value= twoPlaces(round(eval((docor.tot1.value)+"+"+ (docor.tot2.value)+"+"+ (docor.tot3.value)+"+"+ (docor.tot4.value)+"+"+(docor.tot5.value))));

		docor.disctotal.value= twoPlaces(Math.round(eval(docor.subtotal.value*discount/100)*div)/div);

		docor.exvattotal.value= twoPlaces(round(eval((docor.subtotal.value)+"+"+(docor.deltotal.value)+"-"+(docor.disctotal.value))));
		
		docor.vat.value= twoPlaces(round(eval(docor.exvattotal.value*vatrate/100)));

		docor.finaltotal.value= twoPlaces(round(eval((docor.exvattotal.value)+"+"+ (docor.vat.value)+"+"+ (docor.deltotal.value))));


return docor.deltotal.value;docor.subtotal.value;docor.disctotal.value;docor.exvattotal.value;docor.vat.value;docor.finaltotal.value;
	}

	
function sendoffOrder(workbench_order){      //form name
	var docor=document.workbench_order      //form name
	// form validation code
	addPrice();
	WorkitOut();
	TotalitUp();


		if (docor.subtotal.value=="NaN") {
	alert("You do not appear to have entered a correct product reference\nPlease check and re-enter.");
	docor.refno1.focus();
	return false;
}

	if (docor.finaltotal.value=="0.00") {
	alert("You do not appear to have ordered anything!\nPlease enter a product reference number and quantity required.");
	docor.refno1.focus();
	return false;
}
	
	if (docor.name.value=="") {
	alert("May we have your name please?");
	docor.name.focus();
	return false;
}
	
	if (docor.tel.value=="") {
	alert("May we have a contact telephone number please?\n\nEither enter your number or \"none\"");
	docor.tel.focus();
	return false;
}
	
	if (docor.email.value=="") {
	alert("May we have your email address please?");
	docor.email.focus();
	return false;
}
	
	if (docor.address.value=="") {
	alert("May we have your address please?\n\nWe cannot proceed with the order without it.");
	docor.address.focus();
	return false;
}
	
if(confirm("Thank you for your order\nYour order total is £"+docor.finaltotal.value+"."))	{
	orderSent=true;
	// return true to allow submission
docor.action="http://www.v63.net/cgi-bin/cgiemail/workbenchorder23.txt" //change name
	return(true);
	
	}
else
	{
	//  do nothing but return false to prevent submission
	return(false);
	}
}	
	
			function clearProdInfo(){
		var docor=document.workbench_order      //form name
	docor.refno1.focus();
	docor.refno1.value="";docor.desc1.value="";docor.opt1.value="";docor.qty1.value="";docor.listp1.value="";
docor.refno2.focus();
	docor.refno2.value="";docor.desc2.value="";docor.opt2.value="";docor.qty2.value="";docor.listp2.value="";
docor.refno3.focus();
	docor.refno3.value="";docor.desc3.value="";docor.opt3.value="";docor.qty3.value="";docor.listp3.value="";
docor.refno4.focus();
	docor.refno4.value="";docor.desc4.value="";docor.opt4.value="";docor.qty4.value="";docor.listp4.value="";
	docor.refno5.blur();	
	docor.refno5.value="";docor.desc4.value="";docor.opt4.value="";docor.qty4.value="";docor.listp4.value="";
	docor.refno1.blur();	
	WorkitOut();TotalitUp();cookieForms('save', 'workbench_order')      //form name
	}
	
	function clearCustomerInfo(){
		var docor=document.workbench_order      //form name
	docor.name.value="";docor.company.value="";docor.tel.value="";docor.fax.value="";docor.email.value="";docor.address.value="";docor.delivery.value="";docor.additional.value="";docor.order_ref.value="";
	}
	
		function addWhereFrom(){
		var docor=document.workbench_order      //form name
	if(docor.wherefromref.value=="")(docor.wherefromref.value="refer:"+document.referrer+"\nland:"+document.location+".");
}

function killCook(){
	if (document.cookie!=""){
	thisCookie=document.cookie.split("; ")
	expireDate=new Date
	expireDate.setDate(expireDate.getDate()-1)}
	}
	
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Nick Baker -->

<!-- Begin
// Cookie Functions  ////////////////////  (:)
// Set the cookie.
// SetCookie('your_cookie_name', 'your_cookie_value', exp);

// Get the cookie.
// var someVariable = GetCookie('your_cookie_name');


var expDays = 100;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


function getCookieVal (offset) {  

	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) {  

	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;

}

function SetCookie (name, value) {  

	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}


// cookieForms saves form content of a page.

// use the following code to call it:

//  <body onLoad="cookieForms('open', 'form_1', 'form_2', 'form_n')" onUnLoad="cookieForms('save', 'form_1', 'form_2', 'form_n')">
// It works on text fields and dropdowns in IE 5+
// It only works on text fields in Netscape 4.5


function cookieForms() {  

	var mode = cookieForms.arguments[0];

	for(f=1; f<cookieForms.arguments.length; f++) {
		formName = cookieForms.arguments[f];
		if(mode == 'open') {	
			cookieValue = GetCookie('saved_'+formName);
			if(cookieValue != null) {
				var cookieArray = cookieValue.split('#cf#');
	

				if(cookieArray.length == document[formName].elements.length) {
					for(i=0; i<document[formName].elements.length; i++) {
		

						if(cookieArray[i].substring(0,6) == 'select') { document[formName].elements[i].options.selectedIndex = cookieArray[i].substring(7, cookieArray[i].length-1); }
						else if((cookieArray[i] == 'cbtrue') || (cookieArray[i] == 'rbtrue')) { document[formName].elements[i].checked = true; }
						else if((cookieArray[i] == 'cbfalse') || (cookieArray[i] == 'rbfalse')) { document[formName].elements[i].checked = false; }
						else { document[formName].elements[i].value = (cookieArray[i]) ? cookieArray[i] : ''; }
					}
				}
			}
		}
	
		if(mode == 'save') {	

			cookieValue = '';
			for(i=0; i<document[formName].elements.length; i++) {
				fieldType = document[formName].elements[i].type;
				
				if(fieldType == 'password') { passValue = ''; }
				else if(fieldType == 'checkbox') { passValue = 'cb'+document[formName].elements[i].checked; }
				else if(fieldType == 'radio') { passValue = 'rb'+document[formName].elements[i].checked; }
				else if(fieldType == 'select-one') { passValue = 'select'+document[formName].elements[i].options.selectedIndex; }
				else { passValue = document[formName].elements[i].value; }

				cookieValue = cookieValue + passValue + '#cf#';
			}
			cookieValue = cookieValue.substring(0, cookieValue.length-4); // Remove last delimiter
			
			SetCookie('saved_'+formName, cookieValue, exp);		
		}	
	}
}

//  End -->
