var cTape="";

function optiontr(c)
{ var op = document.fm.elements["pOption[]"][1];
  op.value = c;
  reOption(op);
  return false; }
function reBorder(t)
{ if (t=="no selection") {t="";}
  if (cTape)
  { var x = "document.getElementById(\"" + cTape + "\").style.borderColor=\"transparent\""; eval(x); }
  cTape = t;
  if (t) {var x = "document.getElementById(\"" + t + "\").style.borderColor=\"#b6a4b7\""; eval(x);} }

function reOption(o)
{ var p = o.selectedIndex;
  var s = o.value;
  reBorder(s);
  var f = getFline(s);
  if (p==0) {var ax=dopts;}
  else if (s.substr(0,1)=="-") {var ax=popts;}
  else {var ax=copts;}
  var ns = "|" + f;
  var op = document.fm.elements["pOption2[]"][f];
  op.length = 0; var c = 0;
  for (i=0; i < (ax.length); i++)
  { if (i==0 || ax[i].indexOf(".") == -1)
    { var ac = ax[i].split("|");
	var xopt = ac[0];
	var xtxt = ac[1];
	if (p > 0) {xopt += ns;}
	var nOpt = new Option(xtxt);
	op.options[c] = nOpt;
	op.options[c].value = xopt; ++c; } }
  document.fm.elements["pOption2[]"][f].selectedIndex = 0; }

function reProduct(o)
{ var p = o.selectedIndex;
  var s = o.value;
  var f = getFline(s);
  if (p==0) {var a=0; var b=0;}
  else if (s.substr(0,1)=="-") {var a=2+p; var b=2;}
  else {var a=p; var b=1;}
  document.fm.elements["pNum[]"][f].value = skus[a];
  document.fm.elements["pName[]"][f].value = nams[b];
  document.fm.elements["pPrice[]"][f].value = prcs[a]; }
