var userAgent = navigator.appName + " " + navigator.appVersion;

var agentInfo = userAgent.substring(0, 12);



function computeForm(form)

{

 form.total_10010.value= form.qty_10010.value * 1 * 150.00 * 1;

 form.total_10020.value= form.qty_10020.value * 1 * 110.00 * 1;

 form.total_11030.value= form.qty_11030.value * 1 * 150.00 * 1;

 form.total_11040.value= form.qty_11040.value * 1 * 140.00 * 1;

 form.total_11050.value= form.qty_11050.value * 1 * 175.00 * 1;

 form.total_20020.value= form.qty_20020.value * 1 * 130.00 * 1;

 form.total_20010.value= form.qty_20010.value * 1 * 100.00 * 1;

 form.total_30010.value= form.qty_30010.value * 1 * 40.00 * 1; 

 form.total_20110.value= form.qty_20110.value * 1 * 90.00 * 1;

 form.total_20120.value= form.qty_20120.value * 1 * 115.00 * 1;

 form.total_30110.value= form.qty_30110.value * 1 * 37.00 * 1;

 form.total_50000.value= form.qty_50000.value * 1 * 110.00 * 1;

 form.total_50010.value= form.qty_50010.value * 1 * 130.00 * 1;

 form.total_50020.value= form.qty_50020.value * 1 * 130.00 * 1; 

 form.total_50130.value= form.qty_50130.value * 1 * 120.00 * 1; 

 form.total_40020.value= form.qty_40020.value * 1 * 100.00 * 1; 

 form.total_40030.value= form.qty_40030.value * 1 * 150.00 * 1; 

 form.total_40100.value= form.qty_40100.value * 1 * 50.00 * 1; 

 form.total_40200.value= form.qty_40200.value * 1 * 90.00 * 1; 

 form.SUBTOTAL.value= form.total_10010.value * 1 + form.total_10020.value * 1 + form.total_11030.value * 1 + form.total_11040.value * 1 + form.total_11050.value * 1 + form.total_20020.value * 1 + form.total_20010.value * 1 + form.total_30010.value * 1 + form.total_20110.value * 1 + form.total_20120.value * 1 + form.total_30110.value * 1 + form.total_50000.value * 1 + form.total_50010.value * 1 + form.total_50020.value * 1 + form.total_50130.value * 1 + form.total_40020.value * 1 + form.total_40030.value * 1 + form.total_40100.value * 1 + form.total_40200.value * 1; 

 if (form.SUBTOTAL.value >= 0 && form.SUBTOTAL.value <= 50){ 

  form.SHIPPING.value= 4.05;

  }

  if (form.SUBTOTAL.value >= 50.01 && form.SUBTOTAL.value <= 100){ 

  form.SHIPPING.value= 5.00;

  }

  if (form.SUBTOTAL.value >= 100.01 && form.SUBTOTAL.value <= 200){ 

  form.SHIPPING.value= 5.95;

  }

  if (form.SUBTOTAL.value >= 200.01 && form.SUBTOTAL.value <= 300){

  form.SHIPPING.value= 6.90;

  }

  if (form.SUBTOTAL.value >= 300.01 && form.SUBTOTAL.value <= 400){

  form.SHIPPING.value= 7.85;

  }

  if (form.SUBTOTAL.value >= 400.01 && form.SUBTOTAL.value <= 500){

  form.SHIPPING.value= 8.80;

  }

  if (form.SUBTOTAL.value >= 500.01 && form.SUBTOTAL.value <= 600){

  form.SHIPPING.value= 9.75;

  }

  if (form.SUBTOTAL.value >= 600.01 && form.SUBTOTAL.value <= 700){

  form.SHIPPING.value= 10.70;

  }

  if (form.SUBTOTAL.value >= 700.01 && form.SUBTOTAL.value <= 800){

  form.SHIPPING.value= 11.65;

  }

  if (form.SUBTOTAL.value >= 800.01 && form.SUBTOTAL.value <= 900){

  form.SHIPPING.value= 12.60;

  }

  if (form.SUBTOTAL.value >= 900.01 && form.SUBTOTAL.value <= 10000){

  form.SHIPPING.value= 13.55;

  }

 if (form.Billing_state.value == "CA"){

 form.SALES_TAX.value= form.SUBTOTAL.value * 1 * 0.075 * 1;

 }

 else {

 form.SALES_TAX.value= 0.00;

 }

 form.TOTAL.value= form.SUBTOTAL.value * 1 + form.SALES_TAX.value * 1 + form.SHIPPING.value * 1;  

 form.childreach.value= form.TOTAL.value * 1 * 0.05 * 1;

}



 

function validateData(theNum)

{

    var str=theNum;

    if (agentInfo == "Netscape 4.0")

 {

     var correctedNum = 0;

     var decimalPlace = 0;

  var addOn = "0";

  var isDecimal = false;

     for (var i=0; i < str.length; i++)

     {

         var ch=str.substring(i, i+1);

         if (((ch >= "0") && (ch <= "9")) && (!isDecimal))

         {

          correctedNum *= 10;

       correctedNum += ch * 1;

         }

         else if (((ch >= "0") && (ch <= "9")) && (isDecimal))

         {

    addOn += ch;

    ++decimalPlace;

         }

         else if (ch == ".")

          isDecimal = true;

         else if ((ch != ",") && (ch != "$"))

          alert("The invalid character " + ch + " was detected "+

        "and ignored.");

     }

  if (decimalPlace > 0)

   correctedNum += addOn / pow(decimalPlace);

     return correctedNum;

 }

 else

 {

     for (var z=0; z < str.length; z++)

     {

  var ch=str.substring(z, z+1);

  if (((ch < "0") || (ch > "9")) && (ch != "."))

   return false;

     }

     return true;

        }



}



function calc(input)

{

 if (agentInfo == "Netscape 4.0")

 {

     input.value = validateData(input.value);

     computeForm(input.form);

 }

 else

 {

     if (validateData(input.value))

      computeForm(input.form);

     else

     {

       alert("Please do not use any characters besides numbers on"+

       " this line. Your entry will be erased.");

            input.value = 0;

     }

 }



}



function pow(exp)

{

 var returnTotal = 10;

 for (var j = 1; j < exp; j++)

     returnTotal *= 10;

 return returnTotal;

}


