// JavaScript Document
//
//
var xmlFileAQ = "partlists/products.xml";
var xmlXFileAQ = "partlists/exploded.xml";
var xmlProductAQ = "AQUAHEAT";
var xmlProductAQP = "AQUAHEAT_PLUS";
var xmlExtrasAQ = "AQUAHEAT_EXTRAS";
var xmlExtrasAQP = "AQUAHEAT_PLUS_EXTRAS";


function getExtraParts(formID)
{
    AddToCart(formID);
    if ( document.aquaheat_extras0.rbExtra[1].checked )
        AddToCart(document.aquaheat_extras0);
    if ( document.aquaheat_extras1.rbExtra[1].checked )
        AddToCart(document.aquaheat_extras1);
}


function select_aquaheat(plus)
{
	var x;
	var y = null;
	var z = null;

	loadXMLDoc(xmlFileAQ);
	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 (spl)</th>" );
	document.write( "<th align='center'>HP (cd)</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'><span style='color:red'>Limited Offer:</span></th>" );
	document.write( "<th align='center'>Quantity:</th>" );
	document.write( "</tr>" );
	document.write( "</thead>" );
	document.write( "<tbody>" );
	plus ? x = xmlhttp.responseXML.documentElement.getElementsByTagName(xmlProductAQP) : x = xmlhttp.responseXML.documentElement.getElementsByTagName(xmlProductAQ);
	for (i = 0; i < x.length; i++)
	{
	  document.write( "<tr>" );
	  plus ? document.write( "<form name='aquaheat_plus" + i + "'>" ) :	document.write( "<form name='aquaheat" + i + "'>" );
	  document.write( "<td align='center' valign='middle'><input type='checkbox' name='clipcopy'></td>" );
	  document.write( "<td 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='center' valign='middle'>" );
	  y = x[i].getElementsByTagName( "PART_VOLTS" ) [0].childNodes[0].nodeValue;
	  document.write( y );
	  plus ? z = xmlProductAQP : z = xmlProductAQ;
	  z = z + ": " + y + "V, ";
	  document.write( "</td>" );
	  document.write( "<td align='center' valign='middle'>" );
	  y = x[i].getElementsByTagName( "PART_AMPS_HI" ) [0].childNodes[0].nodeValue;
	  document.write( y );
	  z += y + "/";
	  document.write( "</td>" );
	  document.write( "<td align='center' valign='middle'>" );
	  y = x[i].getElementsByTagName( "PART_AMPS_LO" ) [0].childNodes[0].nodeValue;
	  document.write( y );
	  z += y + "A, ";
	  document.write( "</td>" );
	  document.write( "<td align='center' valign='middle'>" );
	  y = x[i].getElementsByTagName( "PART_SPL" ) [0].childNodes[0].nodeValue;
	  document.write( y );
	  z += y + "spl/";
	  document.write( "</td>" );
	  document.write( "<td align='center' valign='middle'>" );
	  y = x[i].getElementsByTagName( "PART_CD" ) [0].childNodes[0].nodeValue;
	  document.write( y );
	  z += y + "cd";
	  document.write( "<input type='hidden' name='NAME' value='" + z + "' />");
	  document.write( "</td>" );
	  document.write( "<td align='center' valign='middle'>" );
	  document.write( x[i].getElementsByTagName( "MOTOR" ) [0].childNodes[0].nodeValue );
	  document.write( "</td>" );
	  document.write( "<td align='center' valign='middle'>" );
	  document.write( x[i].getElementsByTagName( "IMPELLER" ) [0].childNodes[0].nodeValue );
	  document.write( "</td>" );
	  document.write( "<td align='center' valign='middle'><s>" );
	  document.write( x[i].getElementsByTagName( "PART_PRICE" ) [0].childNodes[0].nodeValue );
	  document.write( "</s></td>" );
	  document.write( "<td align='center' valign='middle' style='color:red'>" );
	  y = x[i].getElementsByTagName( "LIMITED_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( "<td 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='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( "<form name='clip'><textarea name='clip_copy' style='display:none'></textarea></form>" );


   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>" );

   plus ? x = xmlhttp.responseXML.documentElement.getElementsByTagName(xmlExtrasAQP) : x = xmlhttp.responseXML.documentElement.getElementsByTagName(xmlExtrasAQ);
   for (i = 0; i < x.length; i++)
   {
	   document.write( "<tr>" );
	   document.write( "<form name='aquaheat_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>" );
}

function select_aquaheat_exploded(plus)
{
	var x;
	var y = null;
	
	loadXMLDoc(xmlXFileAQ);
	document.write( "<table class='ptable' align='center' width='80%' border='2'>" );
	if (plus)
		document.write( "<caption style='font-size:18px;'>Aquaheat Plus Spa and Hot Tub Pump Part List</caption>");
	else
		document.write( "<caption style='font-size:18px;'>Aquaheat 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>" );
   plus ? x = xmlhttp.responseXML.documentElement.getElementsByTagName(xmlProductAQP) : x = xmlhttp.responseXML.documentElement.getElementsByTagName(xmlProductAQ);
   for (i = 0; i < x.length; i++)
   {
	  document.write( "<tr>" );
	  document.write( "<form name='exploded" + i + "'>" );
	  document.write( "<td align='center' valign='middle'><input type='checkbox' name='clipcopy'></td>" );
	  document.write( "<td align='center' valign='middle'>" );
	  document.write( x[i].getElementsByTagName( "INDEX" ) [0].childNodes[0].nodeValue );
	  document.write( "</td>" );
	  document.write( "<td 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 align='center' valign='middle'>" );
	  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( "<td 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>" );
}


