//
// 
//
var xmlFileSC="partlists/products.xml";
var xmlSupercharger="SUPERCHARGER";
var xmlSupercharger_II="SUPERCHARGER_II";
var xmlSuperchargerExtras = "SUPERCHARGER_EXTRAS";
var xmlXFileSC="partlists/exploded.xml";


function getExtraParts(formID)
{
    AddToCart(formID);
    if ( document.supercharger_extras0.rbExtra[1].checked )
        AddToCart(document.supercharger_extras0);
}


function select_supercharger(sc_plus)
{
    var x;
    var y = null;
    var z = null;

    loadXMLDoc(xmlFileSC);
    document.write( "<table class='ptable' align='center' width='90%' border='2'>" );
    document.write( "<thead>" );
    document.write( "<tr>" );
    document.write( "<th align='center'><input type='button' value='Copy' class='btn-sml' onClick='Copy2Clipboard(false)' ></th>" );
    document.write( "<th align='center'>Model Number</th>" );
    document.write( "<th align='center'>Volts</th>" );
    document.write( "<th align='center'>Amps High</th>" );
    document.write( "<th align='center'>Amps Low</th>" );
    document.write( "<th align='center'>HP (cd)</th>" );
    document.write( "<th align='center'>HP (spl)</th>" );
    document.write( "<th align='center'>Motor Part Number</th>" );
    document.write( "<th align='center'>Impeller</th>" );
    document.write( "<th align='center'>List Price</th>" );
    document.write( "<th align='center'>Quantity:</th>" );
    document.write( "</tr>" );
    document.write( "</thead>" );
    document.write( "<tbody>" );
    sc_plus ? x = xmlhttp.responseXML.documentElement.getElementsByTagName( xmlSupercharger_II ) : x = xmlhttp.responseXML.documentElement.getElementsByTagName( xmlSupercharger );
    y = null;
    z = null;
    
    for (i = 0; i < x.length; i++)
    {
      document.write( "<tr>" );
      sc_plus ? document.write( "<form name='supercharger_ii" + i + "' >" ) : document.write( "<form name='supercharger" + i + "' >" );
      document.write( "<td width='5%' align='center' valign='center'><input type='checkbox' name='clipcopy'></td>" );
      document.write( "<td width='15%' valign='center'>" );
      document.write( x[i].getElementsByTagName( "PART_NUM" ) [0].childNodes[0].nodeValue );
      document.write( "<input type='hidden' name='ID_NUM' value='" + 
                      x[i].getElementsByTagName( "PART_NUM" ) [0].childNodes[0].nodeValue + "' />");
      document.write( "</td>" );
      document.write( "<td width='7%' align='center' valign='center'>" );
      y = x[i].getElementsByTagName( "PART_VOLTS" ) [0].childNodes[0].nodeValue;
      document.write( y );
      z = xmlSupercharger + ": " + y + "V, ";
      document.write( "</td>" );
      document.write( "<td width='6%' align='center' valign='center'>" );
      y = x[i].getElementsByTagName( "PART_AMPS_HI" ) [0].childNodes[0].nodeValue;
      document.write( y );
      z += y + "/";
      document.write( "</td>" );
      document.write( "<td width='6%' align='center' valign='center'>" );
      y = x[i].getElementsByTagName( "PART_AMPS_LO" ) [0].childNodes[0].nodeValue;
      document.write( y );
      z += y + "A, ";
      document.write( "</td>" );
      document.write( "<td width='7%' align='center' valign='center'>" );
      y = x[i].getElementsByTagName( "PART_HP_CC" ) [0].childNodes[0].nodeValue;
      document.write( y );
      z += y + "cd/";
      document.write( "</td>" );
      document.write( "<td width='7%' align='center' valign='center'>" );
      y = x[i].getElementsByTagName( "PART_HP" ) [0].childNodes[0].nodeValue;
      document.write( y );
      z += y + "spl";
      document.write( "<input type='hidden' name='NAME' value='" + z + "' />");
      document.write( "</td>" );
      document.write( "<td width='10%' align='center' valign='center'>" );
      document.write( x[i].getElementsByTagName( "MOTOR" ) [0].childNodes[0].nodeValue );
      document.write( "</td>" );
      document.write( "<td width='8%' align='center' valign='middle'>" );
      document.write( x[i].getElementsByTagName( "IMPELLER" ) [0].childNodes[0].nodeValue );
      document.write( "</td>" );
      document.write( "<td width='12%' align='center' valign='center'>" );
      y = x[i].getElementsByTagName( "PART_PRICE" ) [0].childNodes[0].nodeValue;
      document.write( y );
      if ( y.match(/N\/A/) )
          y = 0;
      else
          y.length == 1 ? y = 0 : y = y.slice( 1, y.length );
      document.write( "<input type='hidden' name='PRICE' value='" + y + "' />");
      document.write( "</td>" );
      document.write( "<td width='10%' align='center' valign='center'>" );
      if ( y == 0 )
      {
          document.write( "&nbsp;" );
      } else {
          document.write( "<input type='text' size=6 maxlength=4 name='QUANTITY' onchange='this.value=CKquantity(this.value)' value='1' /><br />" );
          document.write( "<input type='button' value='Add to Order' class='btn-sml' onClick='getExtraParts(this.form)' /><br />" );
          document.write( "<input type='button' value='View Order' class='btn-sml' onclick='DisplayCartAsWindow()' />" );
      }
      document.write( "</td>" );
      document.write( "</form>" );
      document.write( "</tr>" );
    }
    
    document.write( "</tbody>" );
    document.write( "</table>" );
    
    
    document.write( "<table class='ptable' align='center' width='90%' border='2'>" );
    document.write( "<caption style='font-size:18px'>Select your pump unions, if needed, from the table below.<br /></caption" );
    document.write( "<caption style='font-size:18px'>Prices are valid with pump purchase.</caption" );
    document.write( "<thead>" );
    document.write( "<tr>" );
    document.write( "<th align='center'>&nbsp;</th>" );
    document.write( "<th align='center'>Model Number</th>" );
    document.write( "<th align='center'>Model Description</th>" );
    document.write( "<th align='center'>Quantity</th>" );
    document.write( "<th align='center' style='color:red'>Limited Offer</th>" );
    document.write( "</tr>" );
    document.write( "</thead>" );
    document.write( "<tbody>" );
    
    x = xmlhttp.responseXML.documentElement.getElementsByTagName(xmlSuperchargerExtras);
    for (i = 0; i < x.length; i++)
    {
       document.write( "<tr>" );
       document.write( "<form name='supercharger_extras" + i + "'>" );
	   document.write( "<td align='left' valign='middle'>" );
	   document.write( "<input type='radio' value='0' checked='true' name='rbExtra'>Not needed<br />" );
	   document.write( "<input type='radio' value='1' name='rbExtra'>Add to Order" );
	   document.write( "</td>" );
	   document.write( "<td align='left' valign='middle'>" );
	   y = x[i].getElementsByTagName( "NUM" ) [0].childNodes[0].nodeValue;
	   document.write( y );
	   document.write( "<input type='hidden' name='ID_NUM' value='" + y + "' />");
	   document.write( "</td>" );
	   document.write( "<td align='left' valign='middle'>" );
	   y = x[i].getElementsByTagName( "DESC" ) [0].childNodes[0].nodeValue;
	   document.write( y );
	   document.write( "<input type='hidden' name='NAME' value='" + y + "' />");
	   document.write( "</td>" );
	   document.write( "<td width='10%' align='center' valign='middle'>" );
	   document.write( "<input type='text' size=4 maxlength=4 name='QUANTITY' onchange='this.value=CKquantity(this.value)' value='1' /><br />" );
	   document.write( "</td>" );
	   document.write( "<td align='center' valign='middle' style='color:red'>" );
	   y = x[i].getElementsByTagName( "PRICE" ) [0].childNodes[0].nodeValue;
	   document.write( y );
	   y.length == 1 ? y = 0 : y = y.slice( 1, y.length );
	   document.write( "<input type='hidden' name='PRICE' value='" + y + "' />");
	   document.write( "</td>" );
       document.write( "</form>" );
       document.write( "</tr>" );
    }
    document.write( "</tbody>" );
    document.write( "</table>" );
    document.write( "<form name='clip'><textarea name='clip_copy' style='display:none'></textarea></form>" );
}


function select_supercharger_exploded(sc_plus)
{
    var x;
    var y = null;

    loadXMLDoc(xmlXFileSC);
       document.write( "<table class='ptable' align='center' width='80%' border='2'>" );
       if (sc_plus)
           document.write( "<caption style='font-size:18px;'>Supercharger II Spa and Hot Tub Pump Part List</caption>");
       else
           document.write( "<caption style='font-size:18px;'>Supercharger Spa and Hot Tub Pump Part List</caption>");
       document.write( "<thead>" );
       document.write( "<tr>" );
       document.write( "<th align='center'><input type='button' value='Copy' class='btn-sml' onClick='CopyExp2Clipboard(false)' ></th>" );
       document.write( "<th align='center'>Index Number:</th>" );
       document.write( "<th align='center'>Part Number:</th>" );
       document.write( "<th align='center'>Description:</th>" );
       document.write( "<th align='center'>List Price:</th>" );
       document.write( "<th align='center'>Quantity:</th>" );
       document.write( "</tr>" );
       document.write( "</thead>");
       document.write( "<tbody>" );
       sc_plus ? x = xmlhttp.responseXML.documentElement.getElementsByTagName( xmlSupercharger_II ) : x = xmlhttp.responseXML.documentElement.getElementsByTagName( xmlSupercharger );

       for (i = 0; i < x.length; i++)
       {
          document.write( "<tr>" );
          document.write( "<form name='exploded" + i + "'>" );
          document.write( "<td width='5%' align='center' valign='middle'><input type='checkbox' name='clipcopy'></td>" );
          document.write( "<td width='15%' align='center' valign='middle'>" );
          document.write( x[i].getElementsByTagName( "INDEX" ) [0].childNodes[0].nodeValue );
          document.write( "</td>" );
          document.write( "<td width='15%' align='center' valign='middle'>" );
          document.write( x[i].getElementsByTagName( "PART_NUM" ) [0].childNodes[0].nodeValue );
          document.write( "<input type='hidden' name='ID_NUM' value='" + 
                          x[i].getElementsByTagName( "PART_NUM" ) [0].childNodes[0].nodeValue + "' />");
          document.write( "</td>" );
          document.write( "<td align='left' valign='middle'>" );
          document.write( x[i].getElementsByTagName( "DESCRIPTION" ) [0].childNodes[0].nodeValue );
          document.write( "<input type='hidden' name='NAME' value='" + 
                          x[i].getElementsByTagName( "DESCRIPTION" ) [0].childNodes[0].nodeValue + "' />");
          document.write( "</td>" );
          document.write( "<td width='15%' align='center' valign='middle'>" );
          y = x[i].getElementsByTagName( "PRICE" ) [0].childNodes[0].nodeValue;
          document.write( y );
          if ( y.match(/N\/A/) )
              y = 0;
          else
              y.length == 1 ? y = 0 : y = y.slice( 1, y.length );
          document.write( "<input type='hidden' name='PRICE' value='" + y + "' />");
          document.write( "</td>" );
          document.write( "<td width='10%' align='center' valign='middle'>" );
          if ( y == 0 )
          {
              document.write( "&nbsp;" );
          } else {
              document.write( "<input type='text' size=6 maxlength=4 name='QUANTITY' onchange='this.value=CKquantity(this.value)' value='1' /><br />" );
              document.write( "<input type='button' value='Add to Order' class='btn-sml' onClick='AddToCart(this.form)' /><br />" );
              document.write( "<input type='button' value='View Order' class='btn-sml' onclick='DisplayCartAsWindow()' />" );
          }
          document.write( "</td>" );
          document.write( "</form>" );
          document.write( "</tr>" );
       }
       document.write( "</tbody>" );
       document.write( "</table>" );
}


