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) { // process selects
var i,j,amt=0,des="",obj,pos,tok,val;
var ary = new Array ();
  if (obj1.baseamt) amt  = obj1.baseamt.value*1.0; // base amount
  if (obj1.basedes) des  = obj1.basedes.value;     // base description
  for (i=0; i<obj1.length; i++) {     // run entire form
    obj = obj1.elements[i];           // a form element
    if (obj.type == "select-one") {   // just get selects
      if (obj.name == "quantity" ||   // don't mess with these
          obj.name == "price") continue;
      pos = obj.selectedIndex;        // which option selected
      val = obj.options[pos].value;   // selected value
      ary = val.split (" ");          // break apart
      for (j=0; j<ary.length; j++) {  // look at all items
// first we do single character tokens...
        if (ary[j].length < 2) continue;
        tok = ary[j].substring (0,1); // first character
        val = ary[j].substring (1);   // get data
        if (tok == "@") amt = val * 1.0;
        if (tok == "+") amt = amt + val*1.0;
        if (tok == "%") amt = amt + (amt * val/100.0);
        if (tok == "#") {             // record item number
          if (obj1.item_number) obj1.item_number.value = val;
          ary[j] = "";                // zap this array element
        }
// Now we 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 == "s1=") {           // value for shipping
          if (obj1.shipping)  obj1.shipping.value  = val;
          ary[j] = "";                // clear it out
        }
        if (tok == "s2=") {           // value for shipping2
          if (obj1.shipping2) obj1.shipping2.value = val;
          ary[j] = "";                // clear it out
        }
      }
      val = ary.join (" ");           // rebuild val with what's left

      if (obj.name == "on0" ||        // let these go where they want
          obj.name == "os0" ||
          obj.name == "on1" ||
          obj.name == "os1") continue;

	  // if this is a PC, make sure to add the dimensions
      if (val.match('PC')) val += ' ' + obj1.dim.value;
      if (des.length == 0) des = val;
      else des = des + ", " + val;
    }
  }
  
  /* 
  	 use a regular expression to remove the
     "+5.00" and "+20.00" from the descriptions.
  
  	 \s = one whitespace character
  	 \+ = literal plus sign
  	 \d+ = one or more numeric characters
  	 \.00  = literal period followed by two zeroes
   
  	 g = replace globally 
  */
  
  des = des.replace(/\s\+\d+\.00/g,'');
  
  // Now summarize stuff we just processed, above
  obj1.product.value = des;
  obj1.price.value = Dollar (amt);
  
  if (obj1.tot) obj1.tot.value = "$" + Dollar (amt);
 
}