var cTape="";
var pref="";
var col="";

var dopts=["no selection|Select ...", "no selection|color ...", "no selection|first ..."];
var copts=["no selection|Select width ...", "1 inch|1 inch", "1/2 inch|1/2 inch"];
var popts=["no selection|Select length ...", "-150 feet|150 feet", "-25 feet|25 feet"];

function verifyTapes(col, len, wid)
{ var qt = document.fm.elements["pQty[]"][1];
  var oc = document.fm.elements["pColor"];
  var ol = document.fm.elements["pLength"];
  var ow = document.fm.elements["pWidth"];
  if (qt.value > 0)
  { if (oc.value == "no selection")
    { x = popAlert("Please select " + col + "."); return false; }
    else if (ol.value == "no selection")
    { x = popAlert("Please select " + len + "."); return false; }
    else if (ow.value == "no selection")
    { x = popAlert("Please select " + len + "."); return false; }
  }
  else
  { return popAlert("You must input a quantity for something."); }
  return true; }

function setPref(s)
{ var arr = s.split("_");
  pref = arr[0]; col = arr[1]; document.fm.elements["pOption[]"][1].value=arr[1]; }

function optiontr(s)
{ document.fm.pColor.value = s;
  reOption(document.fm, 0); }

function reBorder(t)
{ if (t=="no selection") {t="";}
  if (cTape)
  { document.getElementById(cTape).style.borderColor="transparent"; }
  cTape = t;
  if (t) { document.getElementById(t).style.borderColor="#b6a4b7"; } }

function reOption(f, i)
{ if (i==0)
  { reBorder(f.pColor.value);
    setPref(f.pColor.value);
    if (pref=="C")
    { var alen=["","150 ft roll"];
	var awid=["","1 in.","1/2 in."]; }
    else if (pref=="P" || (pref=="M" && col=="Iridescent"))
    { var alen=["","150 ft roll","25 ft roll"];
	var awid=["","1 in."]; }
    else
    { var alen=["","150 ft roll","25 ft roll"];
	var awid=["","1 in.","3/4 in."]; }
    var op = f.pLength; var ix = op.selectedIndex;
    op.length = 0; var c = 0;
    for (i=1; i < alen.length; i++)
    { var nOpt = new Option(alen[i]);
	op.options[c] = nOpt;
	op.options[c].value = alen[i]; ++c; }
    if (ix+1 > op.length) {ix=0;}
    op.selectedIndex = ix;
    var op = f.pWidth; var ix = op.selectedIndex;
    op.length = 0; var c = 0;
    for (i=1; i < awid.length; i++)
    { var nOpt = new Option(awid[i]);
	op.options[c] = nOpt;
	op.options[c].value = awid[i]; ++c; }
    if (ix+1 > op.length) {ix=0;}
    op.selectedIndex = ix;
 }
reProduct(f); }

function reProduct(f)
{ if (pref=="C")
  { var a = 1 + f.pWidth.selectedIndex; var pf = "Cloth "; }
  else if (pref=="P")
  { var a = 3 + f.pLength.selectedIndex; var pf = "Prism "; }
  else
  { var a = 3 + (f.pWidth.selectedIndex * 2) +  f.pLength.selectedIndex; var pf = "Metallic "; }
  document.fm.elements["pNum[]"][1].value = skus[a];
  document.fm.elements["pName[]"][1].value = pf + nams[a];
  document.fm.elements["pPrice[]"][1].value = prcs[a]; }

