// =-=-=-=-=-=-= page utilities and display


function isProductGreen(prodselix) {

 if (Product[prodselix].actsym.indexOf('G') >= 0)
   return 2;
 if (Product[prodselix].actsym.indexOf('g') >= 0)
   return 1;
 return 0;
}

function showProductACTSymbols(prodselix) {

 if (Product[prodselix].actsym.indexOf('A') >= 0)
   document.write( "<img class=\"actsym\" alt=\"ACT Abrasion: HDU\" src=\"graphics/act_abrasion_hdu12.gif\"> &nbsp;");
 else if (Product[prodselix].actsym.indexOf('a') >= 0)
   document.write( "<img class=\"actsym\" alt=\"ACT Abrasion: GCU\" src=\"graphics/act_abrasion_gcu12.gif\"> &nbsp;");

 if (Product[prodselix].actsym.indexOf('F') >= 0)
   document.write( "<img class=\"actsym\" alt=\"ACT Flammability\" src=\"graphics/act_flammability12.gif\"> &nbsp;");
 if (Product[prodselix].actsym.indexOf('C') >= 0)
   document.write( "<img class=\"actsym\" alt=\"ACT Wet &amp; Dry Crocking\" src=\"graphics/act_crocking12.gif\"> &nbsp;");
 if (Product[prodselix].actsym.indexOf('L') >= 0)
   document.write( "<img class=\"actsym\" alt=\"ACT Colorfastness to Light\" src=\"graphics/act_colorfastness12.gif\"> &nbsp;");
 if (Product[prodselix].actsym.indexOf('P') >= 0)
   document.write( "<img class=\"actsym\" alt=\"ACT Physical Properties\" src=\"graphics/act_physical12.gif\"> &nbsp;");
}

function showProductSpecs() {
  // show a listing of product specifications

  document.write( "<table id=\"spectable\" border=\"1\" cellpadding=\"2\">");
  document.write( "<caption><b>Yoma Textiles: Product Specifications</b></caption>");

  document.write( "<tr>");
  document.write( "<th width=\"100\">Fabric</th>");
  document.write( "<th align=\"center\">Pattern</th>");
  document.write( "<th align=\"center\">Color ways</th>");
  document.write( "<th>Content</th>");
  document.write( "<th align=\"center\">Width</th>");
  document.write( "<th>Repeat</th>");
  document.write( "<th align=\"center\">Double Rubs</th>");
  document.write( "<th>Standards</th>");
  document.write( "<th width=\"100\">"
                + "<a href=\"http://www.contracttextiles.org/main.php?view=5_1\" target=\"_blank\">"
                + "ACT Performance"
                + "</a>"
                + "</th>");
  document.write( "<th width=\"20\">"
                + "<a href=\"environmental.html\">"
                + "Green"
                + "</a>"
                + "</th>");
  document.write( "</tr>");

  for (var j = 0; j < Product.length; j++)
  {
    var prodselix = j; // indirect as we may want to re-order the display later
    if (prodselix >= 0)
    {
      var prodname = Product[prodselix].name;
      var stdtext = Product[prodselix].standards;
      if (stdtext != "") {
        stdtext = stdtext.replace(/([^,])( )/g,"$1&nbsp;");
      }

      document.write( "<tr>");

      document.write( "<td>");
      document.write( "<a class=\"prodref\"" // + " onClick=\"gotoProduct(" + prodselix + ",false); return false;\""
                    + " href=\"" + catalogURL(prodselix,false) + "\">");
      document.write( "<span><b>" + prodname + "</b></span>");
      document.write( "</a>");
      document.write( (Product[prodselix].newprodflag)? " - NEW!": "");
      document.write( "</td>");

      document.write( "<td align=\"center\">" + "#" + Product[prodselix].catnum + "</td>"
                    + "<td align=\"center\">" + Product[prodselix].colorways + "</td>" 
                    + "<td>" + Product[prodselix].material + "</td>"
                    + "<td align=\"center\">" + Product[prodselix].width + " " 
                    + "<td>" + ((Product[prodselix].repeat != "") ?
                       Product[prodselix].repeat : 
                       "n/a") + "</td>"
                    + "<td align=\"right\">"+ ((Product[prodselix].dblrubs != "") ?
                       Product[prodselix].dblrubs : 
                       "n/a") + "</td>"
                    + "<td>"+ stdtext + "</td>");

      document.write( "<td>");
      showProductACTSymbols(prodselix);

      document.write( "<td align=\"center\">");
      if (isProductGreen(prodselix) > 0) {
        document.write( "<img alt=\"green\" src=\"graphics/icon_check20.gif\">");
      }
      document.write( "</td>");

      document.write( "</tr>");

    }
  }
  document.write( "</table>");
}

