<!--
	//filename: productMSDS.js
	//project: transtarindustries.com
	//description: dynamically updates the MSDS data lists
	
	function UpdateTBVList()
	{
		//lose the focus on the select box
		document.getElementById( 'hidFocus' ).focus();
		//display the loading notification
		document.getElementById( 'tbvLoading' ).style.display = 'block';
		var strTerms = document.getElementById( 'selTbvMake' ).value;
		var xmlHttp = AJAX_GetXMLHttp();
		if ( xmlHttp == null )
		{
			alert( "Error: Could not instantiate XmlHttp object." );
			return;
		}
		if ( strTerms != '' )
		{
			//update the product search dropdowns
			xmlHttp.open( 'GET', 'technicalTransByVehicleXml.asp?terms=' + strTerms, true );
			xmlHttp.send( 'terms=' + strTerms );
			xmlHttp.onreadystatechange = function()
			{
				if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 )
				{
					//update the list
					ProcessTBVList( xmlHttp.responseText );
				}
			}
		}
		else
		{
			//hide the loading notification
			document.getElementById( 'msdsLoading' ).style.display = 'none';
			//reset the list
			document.getElementById( 'msdsList' ).innerHTML = '';
		}
	}
	function ProcessTBVList( xmlString )
	{
		var xmlDoc;
		var dataset;
		var strTbvMake = '';
		var strTbvModel = '';
		var strTbvYears = '';
		var strTbvSpeed = '';
		var strTbvDriveTrainType = '';
		var strTbvTransmission = '';
		var strHtml = '';
		var i;
		if ( xmlString.length <= 0 )
		{
			return;
		}
		// Instantiate the xml parser
		xmlDoc = AJAX_GetXMLParser();
		if ( xmlDoc == null )
		{
			alert( "Error: Could not instantiate XML parser." );
			return;
		}
		// Load the XML string
		xmlDoc = AJAX_LoadXML( xmlDoc, xmlString );
		if ( xmlDoc == null )
		{
			alert( "Error: Could not parse XML data." );
			return;
		}
		//get the dataset
		dataset = xmlDoc.getElementsByTagName( 'TBVData' );
		if ( dataset.length != 0 )
		{
			//start the table
			strHtml += '<table width=\"450\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"tblTbvList\">';
			//create the table header
			strHtml += '<tr class=\"tblTbvHeader\">';
			strHtml += '<td width=\"85\">Make</td>';
			strHtml += '<td width=\"100\">Model</td>';
			strHtml += '<td width=\"65\">Years</td>';
			strHtml += '<td width=\"50\">Speed</td>';
			strHtml += '<td width=\"60\">Fwd/Rwd</td>';
			strHtml += '<td width=\"90\">Transmission</td>';
			strHtml += '</tr>';
			//loop through the xml data
			for ( var i=0; i < dataset.length; i++ )
			{
				//assign the values
				strTbvMake = dataset[i].childNodes[0].firstChild.nodeValue;
				strTbvModel = dataset[i].childNodes[1].firstChild.nodeValue;
				strTbvYears = dataset[i].childNodes[2].firstChild.nodeValue;
				strTbvSpeed = dataset[i].childNodes[3].firstChild.nodeValue;
				strTbvDriveTrainType = dataset[i].childNodes[4].firstChild.nodeValue;
				strTbvTransmission = dataset[i].childNodes[5].firstChild.nodeValue;
				strHtml += '<tr class=\"tblTbvData\">';
				strHtml += '<td>' + strTbvMake + '</td>';
				strHtml += '<td>' + strTbvModel + '</td>';
				strHtml += '<td>' + strTbvYears + '</td>';
				strHtml += '<td>' + strTbvSpeed + '</td>';
				strHtml += '<td>' + strTbvDriveTrainType + '</td>';
				strHtml += '<td><strong>' + strTbvTransmission + '</strong></td>';
				strHtml += '</tr>';
			}
			//close up the table
			strHtml += '</table>';
			//hide the loading notification
			document.getElementById( 'tbvLoading' ).style.display = 'none';
			//set the content of the Upgrade box
			document.getElementById( 'tbvList' ).innerHTML = strHtml;
		}
		else
		{
			//hide the loading notification
			document.getElementById( 'tbvLoading' ).style.display = 'none';
			//notify the user
			document.getElementById( 'tbvList' ).innerHTML = '<p>There are currently no Transmission by Vehicle information for the selected manufacturer. Please check back soon for updates.</p>';
		}
	}
	function GetTBVList()
	{
		if ( document.getElementById( 'selTbvMake' ).value != '' )
		{
			UpdateTBVList();
		}
		else
		{
			//hide the loading notification
			document.getElementById( 'tbvLoading' ).style.display = 'none';
			//reset the list
			document.getElementById( 'tbvList' ).innerHTML = '';
		}
	}
//-->