function pickPrice(f, ttl) {
  // A radio button wasn't specified.
  var a,sel = false;
  for (a = 0; a < ttl ; a++) { if (f.price_box[a].checked == true) { sel = true; } }
  if (sel != true) {
    alert("Please choose size and frame options,\nand click the corresponding price in the grid.");
    return false;
  }
  // All good so far; send into post-production function.
  ReadForm(f, true);
}
function checkThree(f, ttl) {
  // Count checked checkboxes.
  var checkCount = 0;
  var msg = "";
  if (f.print_1.checked == true) checkCount++;
  if (f.print_2.checked == true) checkCount++;
  if (f.print_3.checked == true) checkCount++;
  if (f.print_4.checked == true) checkCount++;
  if (f.print_5.checked == true) checkCount++;
  if (f.print_6.checked == true) checkCount++;
  // Check three and only three.
  if (checkCount != 3) {
  if (checkCount > 0) msg = "You selected " + checkCount + " print" + (checkCount == 1 ? "" : "s") + ".\n\n";
    msg += "Please click exactly three of the check boxes,\nto indicate your choice of three prints for this set.";
    alert(msg);
    return false;
  }
  // All good so far; go on to check radio buttons (and from there, post-production...).
  return pickPrice(f, ttl);
}
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, tst) { // process radio and checkbox
  var i,amt,des,obj,pos,val,onval,osval,i_n;
  amt = obj1.baseamt.value*1.0;    // base amount
  des = obj1.basedes.value;        // base description
  i_n = obj1.base_item_name.value; // base item name
  for (i=0; i<obj1.length; i++) {  // run entire form
    obj = obj1.elements[i];        // a form element
    if (obj.type == "checkbox" ||  // checkboxes
        obj.type == "radio") {     //  and radios
      if (obj.checked) {           // did user check it?
        val = obj.value;           // the value of the selection
        pos  = val.indexOf ("@");  // price set?
        if (pos > 0) {
          amt = val.substring (pos + 1)*1.0;
          val = val.substring (0, pos);	// remove dollar value from description string
        }
        pos  = val.indexOf ("+");  // price increment?
        if (pos > 0) amt = amt + val.substring (pos + 1)*1.0;
        pos  = val.indexOf ("%");  // percent change?
        if (pos > 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
        // Sidetrack any values that should only affect item_name.
        if (val.substring(0, 12) == 'item_name:::') {
          if (i_n.length == 0) {
            i_n = val.substring(12);
          } else if (i_n.charAt(i_n.length - 1) == ":") {
            i_n = i_n + " " + val.substring(12);  // don't add comma after colon in description
          } else {
            i_n = i_n + ", " + val.substring(12);  // accumulate values
          }
        // Let this value affect description.
        } else {
          if (des.length == 0) {
            des = val;
          } else if (des.charAt(des.length - 1) == ":") {
            des = des + " " + val;  // don't add comma after colon in description
          } else {
            des = des + ", " + val;  // accumulate values
          }
        }
      }
    }
  }
  // Split option on triple-colon delimiter.
  pos = des.indexOf(":::");
  if (pos > 0) {
    onval = des.substring(0, pos); osval = des.substring(pos + 3);
  } else {
    onval = des; osval = "";
  }
  // Add any item_name extra values to its description.
  obj1.item_name.value = i_n;
  obj1.on0.value = onval;
  obj1.os0.value = osval;
  obj1.amount.value = Dollar (amt);
}
