
function displayColor (idx) {
  var targetdoc = top.frames['display'].document;
  var targetform = targetdoc.forms['displayform'];
  //var i;
  //var rv;
  //for (i in targetform.colorName) {
  //  rv += (i + " == " + targetform.colorName[i] + "\n");
  //}
  //debug_popup(rv);
  //return;
  if (idx) {
  targetform.colorName.value = colorObjects[idx].colorName;
  targetform.price2.value = colorObjects[idx].prices[0];
  targetform.price8.value = colorObjects[idx].prices[1];
  targetform.price1.value = colorObjects[idx].prices[2];
  targetform.price5.value = colorObjects[idx].prices[3];
  targetform.price10.value = colorObjects[idx].prices[4];
  targetform.price25.value = colorObjects[idx].prices[5];
  targetform.price50.value = colorObjects[idx].prices[6];
  targetform.price110.value = colorObjects[idx].prices[7];
  var handle2 = "PR" + idx + "-2";
  var handle8 = "PR" + idx + "-8";
  var handle1 = "PR" + idx + "-1";
  var handle5 = "PR" + idx + "-5";
  var handle10 = "PR" + idx + "-10";
  var handle25 = "PR" + idx + "-25";
  var handle50 = "PR" + idx + "-50";
  var handle110 = "PR" + idx + "-110";
  

var stockinfohtml = ("<span style=\"color:#000000;font-weight:bold;\">StockInfo: </span>" + handle2 + ":" + stockinfo[handle2] + "<br>" + handle8 + ":" + stockinfo[handle8] + "<br>" + handle1 + ":" + stockinfo[handle1] + "<br>" + handle5 + ":" + stockinfo[handle5] + "<br>" + handle10 + ":" + stockinfo[handle10] + "<br>" + handle25 + ":" + stockinfo[handle25] + "<br>" + handle50 + ":" + stockinfo[handle50] + "<br>" + handle110 + ":" + stockinfo[handle110]);
var stockinfotext = ("Stockinfo:\n" + handle2 + ":" + stockinfo[handle2] + "\n" + handle8 + ":" + stockinfo[handle8] + "\n" + handle1 + ":" + stockinfo[handle1] + "\n" + handle5 + ":" + stockinfo[handle5] + "\n" + handle10 + ":" + stockinfo[handle10] + "\n" + handle25 + ":" + stockinfo[handle25] + "\n" + handle50 + ":" + stockinfo[handle50] + "\n" + handle110 + ":" + stockinfo[handle110]);
  // targetform.stockinfo.value = stockinfotext;
  top.frames['chooser'].frames['quickentry'].document.forms['entryform'].stockinfo.value = stockinfotext;
  // writeMessageWindow(stockinfohtml);
  
		  if (colorObjects[idx].stockbase) {
			targetdoc.images['colorchip'].src = (colorchipsDir + "/" + idx + colorchipFilesuffix);
		  } else {
			targetdoc.images['colorchip'].src = ("/images/eng/general/clear.gif");
		  }


  targetdoc.images['colorchip'].src = (colorchipsDir + "/" + idx + colorchipFilesuffix);
  }
  return true;
}
function clearDisplay () {
  return false;
}





function writeMessageWindow(theMessage) {
var pageHTML = "";

pageHTML += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"";
pageHTML += "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">";
pageHTML += "<HTML>";
pageHTML += "<HEAD>";
pageHTML += "<TITLE>blank</TITLE>";
pageHTML += "</HEAD>";
pageHTML += "<BODY BGCOLOR=\"#FFFFFF\">";
pageHTML += "<DIV style=\"background-color:#FFFFFF;display:block;font-family:Verdana,Arial,Helvetica;font-size:10px;color:#CC0000;\">";
pageHTML += theMessage;
pageHTML += "</DIV>";
pageHTML += "</BODY>";
pageHTML += "</HTML>";


top.frames['message'].document.open();
top.frames['message'].document.write(pageHTML);
top.frames['message'].document.close();

return(false);
}




// functions to display lines in the display frame

function displayLines () {
var counter = orderLines.length - 1;
var rv = "";
var dl = "";
var subtotal = 0;
var target = parent.frames['palette'].document;
target.open();
while (counter > -1) {
 if (orderLines[counter].idx) {
  subtotal += orderLines[counter].linetotal;
  dl += getOrderLine(orderLines[counter]);
 }
 counter--;
}
rv += ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\"><HTML>\n<HEAD>\n<TITLE>Colors In Your Palette</TITLE>\n<link rel=\"Stylesheet\" rev=\"Stylesheet\" href=\"/css/colorwizards.1.css\" type=\"text/css\">\n</HEAD>\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" BACKGROUND=\"/images/eng/headers/bg_tile_tan.gif\">");
rv += ("<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"1\" WIDTH=\"100%\">\n");
rv += ("<FORM ACTION=\"/cgi-bin/webcart.cgi\" METHOD=\"POST\" TARGET=\"_top\" onSubmit=\"return parent.frames['chooser'].checkSubmit(document.forms[0]);\">\n");
rv += ("<INPUT TYPE=\"HIDDEN\" NAME=\"page\" VALUE=\"popup\">\n");
rv += ("<INPUT TYPE=\"HIDDEN\" NAME=\"row\" VALUE=\"popup\">\n");
rv += ("<INPUT TYPE=\"HIDDEN\" NAME=\"mode\" VALUE=\"add\">\n");
rv += ("<TR>\n");
rv += ("<TD COLSPAN=\"1\" ALIGN=\"CENTER\" NOWRAP WIDTH=\"90%\"><span STYLE=\"font-size:18px;font-family:Trebuchet MS, Verdana, Arial;font-weight:bold;\">Color Palette</span></TD>\n");
rv += ("<TD COLSPAN=\"1\" ALIGN=\"CENTER\" NOWRAP WIDTH=\"1%\"><INPUT TYPE=\"BUTTON\" VALUE=\"Recalculate\" CLASS=\"cartbutton\" onClick=\"return parent.frames['chooser'].recalcLines();\"></TD>\n");
rv += ("<TD COLSPAN=\"1\" ALIGN=\"CENTER\" NOWRAP WIDTH=\"1%\"><INPUT TYPE=\"SUBMIT\" VALUE=\"Add To Cart\" CLASS=\"cartbutton\" onClick=\"parent.frames['chooser'].hardSubmit(document.forms[0]);\"></TD>\n");
rv += ("<TD COLSPAN=\"1\" ALIGN=\"CENTER\" NOWRAP WIDTH=\"1%\"><span style=\"font-family:Verdana,Arial,Helvetica; color:#003300\; font-weight: bold;\">subtotal:</span><INPUT TYPE=\"TEXT\" READONLY SIZE=\"12\" NAME=\"subtotal\" value=\"" + subtotal + "\"></TD>\n");
rv += ("<TD COLSPAN=\"1\" ALIGN=\"CENTER\" NOWRAP WIDTH=\"1%\"><a href=\"/docs/wizard.html\" onClick=\"return parent.popWindow(\'Help\', this.window, \'/docs/wizard.html\', \'width=400,height=400,resizable,scrollbars=yes,menubar=yes\');\"><img src=\"/images/eng/general/question_mark.gif\" width=\"20\" height=\"20\" align=\"right\" border=\"0\"></a></TD>\n");
rv += ("</TR>");
rv += "</TABLE>\n";
rv += ("<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"1\" WIDTH=\"100%\">\n");
rv += ("<TR>");
// need to make some kind of cartclass for dyes and paints coming from this form.
// this cart class should split differently.  Using the objid won't work because
// it has a hyphen.
rv += ("<INPUT TYPE=\"HIDDEN\" NAME=\"cartclass\" VALUE=\"810001-A\">\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">STOCK#</span></th>\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">ColorChip</span></th>\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">TITLE</span></th>\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">SIZE</span></th>\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">QUANT</span></th>\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">PRICE</span></th>\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">LINETOTAL</span></th>\n");
rv += ("<TH ALIGN=\"CENTER\"><span class=\"PRICELABEL\">Remove</span></th>\n");
rv += ("</TR>\n");
rv += dl;
rv += "</TABLE>\n";
rv += "<BR CLEAR=\"ALL\">";

rv += "\n<IMG SRC=\"/images/eng/general/clear.gif\" HEIGHT=\"300\" WIDTH=\"600\">\n";

target.write(rv);
target.write("\n</FORM></BODY>\n</HTML>");
target.close();
return false;
}


function getOrderLine (orderLineObject) {
 var rv = "";
 rv += ("<TR>\n");
 rv += ("<TD ALIGN=\"CENTER\"><INPUT TYPE=\"TEXT\" NAME=\"displaystocknum" + orderLineObject.linenum + "\" SIZE=\"10\" VALUE=\"PR" + orderLineObject.idx + "-" + orderLineObject.size + "\">\n");
 rv += ("<INPUT TYPE=\"HIDDEN\" NAME=\"stocknum" + orderLineObject.linenum + "\" SIZE=\"10\" VALUE=\"PR" + orderLineObject.idx + "-" + orderLineObject.size + "\">\n");
 rv += ("<INPUT TYPE=\"HIDDEN\" NAME=\"vcode" + orderLineObject.linenum + "\" SIZE=\"10\" VALUE=\"" + orderLineObject.idx + "\"></TD>\n");
 rv += ("<TD ALIGN=\"CENTER\"><img src=\"" + colorchipsDir + "-pixels/" + orderLineObject.idx + colorchipFilesuffix + "\" WIDTH=\"60\" HEIGHT=\"20\"></TD>\n");
 rv += ("<TD><span class=\"PRICELABEL\"><B>" + orderLineObject.title + "</B></FONT></TD>\n");
 rv += ("<TD ALIGN=\"CENTER\"><SELECT NAME=\"size" + orderLineObject.linenum + "\" onChange=\"parent.frames['chooser'].recalcLines();\">");
 rv += ("<OPTION VALUE=\"2\" ");
 if (orderLineObject.size == 2) {
   rv += (" SELECTED ");
 }
 rv += (">2 oz.");
 rv += ("<OPTION VALUE=\"8\" ");
 if (orderLineObject.size == 8) {
   rv += (" SELECTED ");
 }
 rv += (">8 oz.");
 rv += ("<OPTION VALUE=\"1\" ");
 if (orderLineObject.size == 1) {
   rv += (" SELECTED ");
 }
 rv += (">1 lb.");
 rv += ("<OPTION VALUE=\"5\" ");
 if (orderLineObject.size == 5) {
   rv += (" SELECTED ");
 }
 rv += (">5+ lbs.");
 rv += ("<OPTION VALUE=\"10\" ");
 if (orderLineObject.size == 10) {
   rv += (" SELECTED ");
 }
 rv += (">10+ lbs.");
 rv += ("<OPTION VALUE=\"25\" ");
 if (orderLineObject.size == 25) {
   rv += (" SELECTED ");
 }
 rv += (">25+ lbs.");
 rv += ("<OPTION VALUE=\"50\" ");
 if (orderLineObject.size == 50) {
   rv += (" SELECTED ");
 }
 rv += (">50+ lbs.");
 rv += ("<OPTION VALUE=\"110\" ");
 if (orderLineObject.size == 110) {
   rv += (" SELECTED ");
 }
 rv += (">110+ lbs.");
 rv += ("</SELECT></TD>\n");
 rv += ("<TD ALIGN=\"CENTER\"><INPUT TYPE=\"TEXT\" onChange=\"parent.frames['chooser'].recalcLines();\" NAME=\"quant" + orderLineObject.linenum + "\" SIZE=\"4\" VALUE=\"" + orderLineObject.quant  + "\"></TD>\n");
 rv += ("<TD ALIGN=\"CENTER\"><INPUT TYPE=\"TEXT\" NAME=\"price" + orderLineObject.linenum + "\" SIZE=\"6\" VALUE=\"" + orderLineObject.price + "\"></TD>\n");
 rv += ("<TD ALIGN=\"CENTER\"><INPUT TYPE=\"TEXT\" NAME=\"linetotal" + orderLineObject.linenum + "\" SIZE=\"8\" VALUE=\"" + orderLineObject.linetotal  + "\"></TD>\n");
 rv += ("<TD ALIGN=\"CENTER\"><A HREF=\"error.html\" onClick=\"return parent.frames['chooser'].removeLine(" + orderLineObject.linenum + ");\">Remove</a></TD>\n");
 rv += ("</TR>\n");
 return(rv);
}


