var SAmts1 = 0.00,SAmts3 = 0.00,SAmts2 = 0.00,SAmts4 = 0.00,SAmts5 = 0.00;
var STax = 0.00,SSubTotal = 0.00,STotal = 0.00;
var s1 ="",s3 = "",s2 = "",s4 = "",s5 = "";
var SShipping = 0;
/*****************
** Add a decimal point to a number
*/

function AddDecimal(number) {
  var withdecimal = "";
  var num = "" + number;
  if (num.length == 0) {
    withdecimal += "0";
  } else if (num.length == 1) {
    withdecimal += "0.0" + num;
  } else if (num.length == 2) {
    withdecimal += "0." + num;
  } else {
  withdecimal += num.substring(0, num.length - 2);
  withdecimal += "."
  withdecimal += num.substring(num.length - 2, num.length);
  }
  return withdecimal;
}


function compute(form)
{
 if (form.country.value == 'canRates') {
	 STaxAmount = 0.13;
 }
 else {
		 STaxAmount = 0;
 }
	 
 SAmts1 = Math.round(eval(form.s1.value * 4800));
 SAmts2 = Math.round(eval(form.s2.value * 6500));
 SAmts3 = Math.round(eval(form.s3.value * 7900));
 SAmts4 = Math.round(eval(form.s4.value * 9000));
 SAmts5 = Math.round(eval(form.s5.value * 9800));

 SSubTotal = (SAmts1 + SAmts3  + SAmts2 + SAmts4 + SAmts5);
 
 STax = (SAmts1 + SAmts3  + SAmts2 + SAmts4 + SAmts5) * STaxAmount;

 STotal =(SAmts1 + SAmts3  + SAmts2 + SAmts4 + SAmts5 + STax);
/* STotal =(SAmts1 + SAmts3  + SAmts2 + SAmts4 + SAmts5);  */

 form.Amts1.value = AddDecimal(SAmts1);
 form.Amts3.value = AddDecimal(SAmts3);
 form.Amts2.value = AddDecimal(SAmts2);
 form.Amts4.value = AddDecimal(SAmts4);
 form.Amts5.value = AddDecimal(SAmts5); 
 form.Tax.value = AddDecimal(STax);
 form.SubTotal.value = AddDecimal(SSubTotal);
 form.Total.value = AddDecimal(STotal);
}

function ClearForm(form) {
form.s1.value = "";
form.s2.value = "";
form.s3.value = "";
form.s4.value = "";
form.s5.value = "";


SAmts1 = 0;
form.Amts1.value = 0;
SAmts3 = 0;
form.Amts3.value = 0;
SAmts2 = 0;
form.Amts2.value = 0;
SAmts4 = 0;
form.Amts4.value = 0;
SAmts5 = 0;
form.Amts5.value = 0;

form.Tax.value = 0;

SSubTotal = 0;
form.SubTotal.value = 0;

STotal = 0;
form.Total.value = 0;
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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') { num = parseFloat(val);
        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 (num<min || max<num) 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 == '');
}