<!--

var discnt = 0;   // no default percent discount

var coupons = new Array (  // place to put coupon codes
//  "46000",
  "WSBW450",
  "46140",
  "QL10",
  "QL2010",
  "LADC",
  "PAWS"			// no comma after last value
);
var coupdc  = new Array (  // place to put discounts for coupon vals
//  40,
  50,
  20,
  10,
  10,
  0,
  0			// no comma after last value
);
var coupval = "(blanket)"; // what user entered as coupon code

function ChkCoup () {      // check user coupon entry
var i;
  discnt = 0;              // assume the worst
  for (i=0; i<coupons.length; i++) {
    if (coupval == coupons[i]) {
      discnt = coupdc[i];  // remember the discount amt
      alert ("Valid Voucher Code!");
      return;
    }
  }
  alert ("Voucher code not valid!");
}

function Dollar (val) {      // force to valid dollar amount
var str,pos,rnd=0;
  if (val < .995) rnd = 1;  // for old Netscape browsers
  str = escape (val*1.0 + 0.005001 + rnd);  // float, round, escape
  pos = str.indexOf (".");
  if (pos > 0) str = str.substring (rnd, pos + 3);
  return str;
}

function ReadForm (obj1) {  // apply the discount
var amt,des;
  amt = obj1.baseamt.value*1.0;       // base amount
  des = obj1.basedes.value;           // base description

  if (discnt > 0) {                   // only if discount is active
    amt = Dollar (amt - (amt * discnt/100.0));
    des = des + "  (" + discnt + "% Discount - " + coupval + ")";
  }

  obj1.amount.value = Dollar (amt);
  obj1.item_name.value = des;
}

function SetShip (obj1) {  // record selected shipping option
var j,obj,pos,tok,val,txt;

var ary = new Array ();
  obj = obj1.shp;          // refer to shipping select
  pos = obj.selectedIndex; // get selection
  if (pos == 0) {          // force a selection
    alert ("Please select delivery country!");
    return false;
  }
  obj1.handling.value = "0";
  obj1.handling_cart.value = "0";
  obj1.shipping.value = "0";
  obj1.shipping2.value = "0";
  val = obj.options[pos].value;   // selected value
  txt = obj.options[pos].text;    // the text value
  ary = val.split (" ");          // break apart
  for (j=0; j<ary.length; j++) {  // look at all items
// do 3-character tokens...
    if (ary[j].length < 4) continue;
    tok = ary[j].substring (0,3); // first 3 chars
    val = ary[j].substring (3);   // get data
    if (tok == "hn=")             // value for item handling
      obj1.handling.value  = val;
    if (tok == "hc=")             // value for handling cart
      obj1.handling_cart.value  = val;
    if (tok == "s1=")             // value for shipping
      obj1.shipping.value  = val;
    if (tok == "s2=")             // value for shipping2
      obj1.shipping2.value = val;
  }
 
  obj1.os0.value = txt;           // stuff the text into options field
}

//-->

