var fc5 = 1;

function doLots1(opn)
{ var op1 = document.fm.elements["pOption[]"];
  var qt = document.fm.elements["pQty[]"];
  lg = qt.length - 1;
  var s = "";

  for (i=2; i<=opn; i++)
  { var x = "var op" + i + " = document.fm.elements['pOption" + i + "[]']";
    eval(x); }
  var x = "var ops = [0, op1";
  for (i=2; i<=opn; i++)
  { x += ",op" + i; }
  x += "]"; eval(x);

  for (c=opn; c>0; c--)
  { if (ops[c][lg].value == "no selection") { s = "Please select " + earr[c-1] + "."; } }
  if (s.length<2 && qt[lg].value == 0) {s="Please select quantity."; qt[lg].focus(); qt[lg].select();}

  if (s.length>2) {x = popAlert(s);} else {x = doMore1(opn+1);}
  return false; }
function doMore1(n)
{ var newdiv = document.createElement("div");
  newdiv.innerHTML = document.getElementById("fline").innerHTML;
  var container = document.getElementById("flines");
  container.appendChild(newdiv);
  ++fc; ns = "|" + fc;
  for (i=1; i<n; i++)
  { if (i==1) {s = "pOption[]";} else {s = "pOption" + i + "[]";}
    var x = "var op = document.fm.elements[\"" + s + "\"][" + fc + "]";
    eval(x);
    for (c=1; c < op.length; c++) { op.options[c].value += ns; } }
  return false; }

function doLots2(opn)
{ var op1 = document.fm.elements["pOption5[]"];
  var qt = document.fm.elements["pQty5[]"];
  lg = qt.length - 1;
  var s = "";

  for (i=6; i<=opn; i++)
  { var x = "var op" + i + " = document.fm.elements['pOption" + i + "[]']";
    eval(x); }
  var x = "var ops = [0, op1";
  for (i=6; i<=opn; i++)
  { x += ",op" + i; }
  x += "]"; eval(x);

  for (c=opn-4; c>0; c--)
  { if (ops[c][lg].value == "no selection") { s = "Please select " + earr[c-1] + "."; } }
  if (s.length<2 && qt[lg].value == 0) {s="Please select quantity."; qt[lg].focus(); qt[lg].select();}

  if (s.length>2) {x = popAlert(s);} else {x = doMore2(opn+1);}
  return false; }

function doMore2(n)
{ var newdiv = document.createElement("div");
  newdiv.innerHTML = document.getElementById("fline2").innerHTML;
  var container = document.getElementById("flines2");
  container.appendChild(newdiv);
  ++fc5; ns = "|" + fc5;
  var op = document.fm.elements["pOption5[]"][fc5];
  for (c=1; c < op.length; c++) { op.options[c].value += ns; }
  return false; }

function verifyMe2(sea, seb, sec)
{ var bTotal = 0;
  var bv = document.fm.elements["bQty[]"];
  var bx = document.fm.elements["bOption[]"];
  if (bv)
  { for (i=0; i<bv.length; i++)
    { bTotal += bv[i].value;
	if (bv[i].value>0)
	{ if (bx[i].value == "no selection")
	  { x = popAlert("Please select " + sea + "."); 
	    bv[i].focus(); bv[i].select(); return false; } }
	if (bx[i].selectedIndex > 0 && bv[i].value<1)
	  { x = popAlert("Please select quantity."); 
	    bv[i].focus(); bv[i].select(); return false; }
 } }
  var qt = document.fm.elements["pQty[]"];
  var op = document.fm.elements["pOption[]"];
  var ox = document.fm.elements["pOption2[]"];
  var oy = document.fm.elements["pOption3[]"];
  var pTotal = 0;
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	if (op[i].value == "no selection")
	{ x = popAlert("Please select " + sea + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
	else if (ox[i].value == "no selection")
	{ x = popAlert("Please select " + seb + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
	else if (oy[i].value == "no selection")
	{ x = popAlert("Please select " + sec + "."); 
	  qt[i].focus(); qt[i].select(); return false; } } }
  var qt = document.fm.elements["pQty5[]"];
  var op = document.fm.elements["pOption5[]"];
  var ox = document.fm.elements["pOption6[]"];
  var oy = document.fm.elements["pOption7[]"];
  for (i=0; i<qt.length; i++)
  { if (qt[i].value > 0)
    { pTotal += qt[i].value;
	if (op[i].value == "no selection")
	{ x = popAlert("Please select " + sea + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
	else if (ox[i].value == "no selection")
	{ x = popAlert("Please select " + seb + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
	else if (oy[i].value == "no selection")
	{ x = popAlert("Please select " + sec + "."); 
	  qt[i].focus(); qt[i].select(); return false; }
    } }
  if ((pTotal + bTotal) == 0) { return popAlert("You must input a quantity for something."); }
  return true; }

