<!--
	//filename: productMSDS.js
	//project: transtarindustries.com
	//description: dynamically updates the MSDS data lists
	
	function UpdateMsdsList()
	{
		//lose the focus on the select box
		document.getElementById( 'hidFocus' ).focus();
		//display the loading notification
		document.getElementById( 'msdsLoading' ).style.display = 'block';
		var lngMsgID = document.getElementById( 'selMsgID' ).value;
		var xmlHttp = AJAX_GetXMLHttp();
		if ( xmlHttp == null )
		{
			alert( "Error: Could not instantiate XmlHttp object." );
			return;
		}
		if ( lngMsgID != '' )
		{
			//update the product search dropdowns
			xmlHttp.open( 'GET', 'productsMSDSXml.asp?ID=' + lngMsgID, true );
			xmlHttp.send( 'ID=' + lngMsgID );
			xmlHttp.onreadystatechange = function()
			{
				if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 )
				{
					//update the list
					ProcessMsdsList( xmlHttp.responseText );
				}
			}
		}
		else
		{
			//hide the loading notification
			document.getElementById( 'msdsLoading' ).style.display = 'none';
			//reset the list
			document.getElementById( 'msdsList' ).innerHTML = '';
		}
	}
	function ProcessMsdsList( xmlString )
	{
		var xmlDoc;
		var dataset;
		var lngDatID = 0;
		var strMsdName = '';
		var strMsdDescription = '';
		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( 'MSDSData' );
		if ( dataset.length != 0 )
		{
			//start the table
			strHtml += '<table width=\"450\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"tblMsdsList\">';
			//create the table header
			strHtml += '<tr class=\"tblMsdsHeader\">';
			strHtml += '<td width=\"200\">Name</td>';
			strHtml += '<td width=\"250\">Description</td>';
			strHtml += '</tr>';
			//loop through the xml data
			for ( var i=0; i < dataset.length; i++ )
			{
				//assign the values
				lngDatID = dataset[i].childNodes[0].firstChild.nodeValue;
				strMsdName = dataset[i].childNodes[1].firstChild.nodeValue;
				strMsdDescription = dataset[i].childNodes[2].firstChild.nodeValue;
				strHtml += '<tr class=\"tblMsdsData\">';
				strHtml += '<td><a href=\"data2Download.asp?ID=' + lngDatID +'\">' + strMsdName + '</a></td>';
				if ( strMsdDescription != '-1' ) { strHtml += '<td>' + strMsdDescription + '</td>'; }
				else { strHtml += '<td>&nbsp;</td>'; }
				strHtml += '</tr>';
			}
			//close up the table
			strHtml += '</table>';
			//hide the loading notification
			document.getElementById( 'msdsLoading' ).style.display = 'none';
			//set the content of the Upgrade box
			document.getElementById( 'msdsList' ).innerHTML = strHtml;
		}
		else
		{
			//hide the loading notification
			document.getElementById( 'msdsLoading' ).style.display = 'none';
			//notify the user
			document.getElementById( 'msdsList' ).innerHTML = '<p>There are currently no MSDS information for the selected supplier. Please check back soon for updates.</p>';
		}
	}
	function GetMSDSList()
	{
		if ( document.getElementById( 'selMsgID' ).value != '' )
		{
			UpdateMsdsList();
		}
		else
		{
			//hide the loading notification
			document.getElementById( 'msdsLoading' ).style.display = 'none';
			//reset the list
			document.getElementById( 'msdsList' ).innerHTML = '';
		}
	}
//-->