<!--
function dp(a, b) {
 /*a *= Math.pow(10, b);
 a = Math.floor(a);
 a /=  Math.pow(10, b);*/
 a=Math.round((a)*100)/100;
 return a;
}


function cal2() // TRADE FORM
{
if ((isNaN(document.quote.width.value)==true)||(isNaN(document.quote.height.value)==true)) {
  window.alert("Please enter numbers greater than 0 for your width and height\n"); }

if (document.quote.dimension.value=="cm") {
  var area=(document.quote.width.value)*(document.quote.height.value);
  document.request.width.value=document.quote.width.value; 
  document.request.height.value=document.quote.height.value; 
  document.request.dimension.value=document.quote.dimension.value; 
  //document.request.cost.value=dp(((area*38.00)/10000),2); 
  //document.quote.cost.value=dp(((area*38.00)/10000),2);
  document.request.cost.value=dp(((area*45)/10000),2); 
  document.quote.cost.value=dp(((area*45)/10000),2); }
if (document.quote.dimension.value=="inches") {
  var area=(document.quote.width.value)*(document.quote.height.value);
  document.request.width.value=document.quote.width.value; 
  document.request.height.value=document.quote.height.value; 
  document.request.dimension.value=document.quote.dimension.value; 
  //document.request.cost.value=dp(((area*3.52)/144),2); 
  //document.quote.cost.value=dp(((area*3.52)/144),2);
  document.request.cost.value=dp(((area*4.18)/144),2); 
  document.quote.cost.value=dp(((area*4.18)/144),2); }
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function validate_dropdown(){
	
	if (document.forms.request.name.value=='') {
		
		alert("First Name is a required field");
		return false;
		
	}  else if (document.forms.request.tel.value=='') {
		
		alert("Telephone is a required field");
		return false;
		
	} else if (document.forms.request.email.value=='') {
		
		alert("Email is a required field");
		return false;
		
	} else if (document.forms.request.add1.value=='') {
		
		alert("Address is a required field");
		return false;
		
	} else if (document.forms.request.town.value=='') {
		
		alert("Town is a required field");
		return false;
		
	} else if (document.forms.request.postcode.value=='') {
		
		alert("Postcode is a required field");
		return false;
		
	}  else if (document.forms.request.term.checked==false) {
		
		alert("You must indicate you accept Chainscreen's\nterms and conditions before proceeding");
		return false;
		
	} else {
	
		return true;
	
	}
	
}


function val_check_2() { //v4.0
  var errors='',args=val_check_2.arguments;
	// NO PAYMENT TYPE
	if ((document.proceed.payment_type[0].checked==false)&&(document.proceed.payment_type[1].checked==false)) {
		errors+='Please choose your payment type to make this purchase.       \n'; }
	// CREDIT CARD PAYMENT
	else if (document.proceed.payment_type[1].checked==true) {
		// NO CARDHOLDER
		if (document.proceed.cardholder.value=='') {
			errors+='Please enter a card holder.           \n'; }
		// NO CARDNO
		if (document.proceed.cardno.value=='') {
			errors+='Please enter a card number.           \n'; }
		// NO CARD TYPE
		if (document.proceed.cardtype.value=='') {
			errors+='Please choose a card type, we only accept Visa or Mastercard.           \n'; }
		// NOT FULL ISSUE DATE
		if ((document.proceed.issuemonth.value=='')||(document.proceed.issueyear.value=='')) {
			errors+='Please enter a full issue date.           \n'; }
		// NOT FULL EXPIRY DATE
		if ((document.proceed.expirymonth.value=='')||(document.proceed.expiryyear.value=='')) {
			errors+='Please enter a full expiry date.           \n'; }
		// NO SECURITY
		if (document.proceed.security.value=='') {
			errors+='Please enter a security code, there is a link below to explain what this is.           \n'; }
		}
	if (errors) {
		alert(errors); }
	  document.return_check_2 = (errors == '');
  } 
//-->
