// ------------------------------------------------------------------
//|
//| Filename    : ORDERCAL.JS
//| Language    : JavaScript
//| Description : Computes $ values in order form after each change
//| Copyright   : (c) 2001 Boedeker Plastics, Inc., Scott Baer
//| -----------------------------------------------------------------
//| Ver    Date    Description of modification
//| --- ---------- --------------------------------------------------
//| 00  02-15-2001 sdb: original creation
//| 01  03-01-2001 sdb: moved to external file, first release
//|
//|
// ------------------------------------------------------------------

function compute() {
  with (document.order) {

 // calculate Item 01 ext-value & round/pad unit price & ext-value to two decimals
    sub1 = Item_01_Qty___.value * Item_01_UnPrc$.value;
    ttl = Item_01_UnPrc$.value;
    padtwo(ttl);
    Item_01_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub1 * 100)) / 100);
    padtwo(ttl);
    Item_01_ExPrc$.value = ttl;

 // calculate Item 02 ext-value & round/pad unit price & ext-value to two decimals
    sub2 = Item_02_Qty___.value * Item_02_UnPrc$.value;
    ttl = Item_02_UnPrc$.value;
    padtwo(ttl);
    Item_02_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub2 * 100)) / 100);
    padtwo(ttl);
    Item_02_ExPrc$.value = ttl;

 // calculate Item 03 ext-value & round/pad unit price & ext-value to two decimals
    sub3 = Item_03_Qty___.value * Item_03_UnPrc$.value;
    ttl = Item_03_UnPrc$.value;
    padtwo(ttl);
    Item_03_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub3 * 100)) / 100);
    padtwo(ttl);
    Item_03_ExPrc$.value = ttl;

 // calculate Item 04 ext-value & round/pad unit price & ext-value to two decimals
    sub4 = Item_04_Qty___.value * Item_04_UnPrc$.value;
    ttl = Item_04_UnPrc$.value;
    padtwo(ttl);
    Item_04_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub4 * 100)) / 100);
    padtwo(ttl);
    Item_04_ExPrc$.value = ttl;

 // calculate Item 05 ext-value & round/pad unit price & ext-value to two decimals
    sub5 = Item_05_Qty___.value * Item_05_UnPrc$.value;
    ttl = Item_05_UnPrc$.value;
    padtwo(ttl);
    Item_05_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub5 * 100)) / 100);
    padtwo(ttl);
    Item_05_ExPrc$.value = ttl;

 // calculate Item 06 ext-value & round/pad unit price & ext-value to two decimals
    sub6 = Item_06_Qty___.value * Item_06_UnPrc$.value;
    ttl = Item_06_UnPrc$.value;
    padtwo(ttl);
    Item_06_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub6 * 100)) / 100);
    padtwo(ttl);
    Item_06_ExPrc$.value = ttl;

 // calculate Item 07 ext-value & round/pad unit price & ext-value to two decimals
    sub7 = Item_07_Qty___.value * Item_07_UnPrc$.value;
    ttl = Item_07_UnPrc$.value;
    padtwo(ttl);
    Item_07_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub7 * 100)) / 100);
    padtwo(ttl);
    Item_07_ExPrc$.value = ttl;

 // calculate Item 08 ext-value & round/pad unit price & ext-value to two decimals
    sub8 = Item_08_Qty___.value * Item_08_UnPrc$.value;
    ttl = Item_08_UnPrc$.value;
    padtwo(ttl);
    Item_08_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub8 * 100)) / 100);
    padtwo(ttl);
    Item_08_ExPrc$.value = ttl;

 // calculate Item 09 ext-value & round/pad unit price & ext-value to two decimals
    sub9 = Item_09_Qty___.value * Item_09_UnPrc$.value;
    ttl = Item_09_UnPrc$.value;
    padtwo(ttl);
    Item_09_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub9 * 100)) / 100);
    padtwo(ttl);
    Item_09_ExPrc$.value = ttl;

 // calculate Item 10 subtotal & round/pad unit price & ext-value to two decimals
    sub10 = Item_10_Qty___.value * Item_10_UnPrc$.value;
    ttl = Item_10_UnPrc$.value;
    padtwo(ttl);
    Item_10_UnPrc$.value = ttl;
    ttl = "" + ((Math.round(sub10 * 100)) / 100);
    padtwo(ttl);
    Item_10_ExPrc$.value = ttl;

 // calculate Order SubTotal & round/pad to two decimals
    tot = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10;
    ttl = "" + ((Math.round(tot * 100)) / 100);
    padtwo(ttl);
    Order_SubTot_$.value = ttl;

    }
  }

function padtwo(num) {

 // rounds total to two decimal places
    ttl = "" + ((Math.round(ttl * 100)) / 100);
    dec1 = ttl.substring(ttl.length-3, ttl.length-2);
    dec2 = ttl.substring(ttl.length-2, ttl.length-1);
    if (dec1 != '.') {
 // adds trailing zeroes if necessary
      if (dec2 == '.') ttl += "0";
      else ttl += ".00";
    }
  }



