//
//
//
var xmlFile="partlists/partlist.xml";

function select_parts(xml_part)
{
    var x;
    var y = null;
    var z = null;

    loadXMLDoc(xmlFile);
    document.write( "<table class='parts' align='center' width='100%' border='2' cell-padding='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'><strong>Part</strong></th>" );
    document.write( "<th align='center'><strong>Part Number</strong></th>" );
    document.write( "<th align='center'>Product Type</th>" );
    document.write( "<th align='center'>Part 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>" );
    x = xmlhttp.responseXML.documentElement.getElementsByTagName( xml_part );

    for (i = 0; i < x.length; i++)
    {
        document.write( "<tr>" );
        document.write( "<form name='part_list" + i + "'>" );
        document.write( "<td width='5%' align='center'><input type='checkbox' name='clipcopy'></td>" );
        document.write( "<td width='15%' align='center'>" );
        y = x[i].getElementsByTagName( 'PIC' ) [0].childNodes[0].nodeValue;
        image = "partlists/" + y + ".jpg";
        messages[i] = new Array(image,"","#0033ff");
        z = x[i].getElementsByTagName( "NUM" ) [0].childNodes[0].nodeValue;
        if ( ( y != "ImageNotAvailable" ) && ( z != "324" ) )
        {
            document.write( "<a href='#' onmouseover='doTooltip(event,"+i+")' onmouseout='hideTip()'>" );
        }
        document.write( "<img name='img" + i + "' src=" + image + " width='100px' border='0' /></a>" );
        document.write( "</td>" );
        document.write( "<td width='10%' align='center'>" );
        document.write( z );
        document.write( "<input type='hidden' name='ID_NUM' value='" + z + "' />");
        document.write( "</td>" );
        document.write( "<td width='20%'>" );
        document.write( x[i].getElementsByTagName( "TYPE" ) [0].childNodes[0].nodeValue );
        document.write( "</td>" );
        document.write( "<td width='45%'>" );
        y = x[i].getElementsByTagName( "DESC" ) [0].childNodes[0].nodeValue;
        document.write( y.replace(/\.\.\s/g, ".<br />") );
        if ( z == "1082" )
        {
            document.write( "<br /><a href='includes/megatrol_manifold_assy.pdf'>&lt;Click to view Manifold Assembly Instructions&gt;</a><br />" );
        }
        document.write( "<input type='hidden' name='NAME' value='" + 
                        x[i].getElementsByTagName( "DESC" ) [0].childNodes[0].nodeValue + "' />");
        document.write( "</td>" );
        document.write( "<td align='center'>" );
        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'>" );
        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>" );
    document.write( "<form name='clip'><textarea name='clip_copy' style='display:none'></textarea></form>" );
}


