<!--
// Purpose: To generate HTML via XSLT on an XML source
//
// Limitations: Only works for IE5.5+ and NS7+
//
// Does a quick browser check and then loads the XML and XSLT
// for a transform action. The results are then channeled into
// a <div> or other container tag contained by oItem
//
// Todo: Probably do sanity checks to degrade gracefully on non IE 5.0 browsers
//
// -howard 31 Oct 2003
//
// Extended it to take 1 optional param modifier
// This is kinda of a hack for now
//
// -howard 26 May 2004

// Do the transformation for the relevant kind of browser
function doTrans(oItem, strXSLTfile, strXMLfile, strParam, strValue)
{
	var bNS7 = !document.all && document.getElementById;
	var bIE4 = (document.all) ? true:false

	if (bIE4)
	{
		var oXML 
		var oXSL 
		var xslHTML 
		
		// Create XML objects
		oXML = new ActiveXObject("Microsoft.XMLDOM"); 
		oXML.async = false; 
		oXSL = new ActiveXObject("Microsoft.XMLDOM"); 
		oXSL.async = false; 
		
		// Load xsl and transform the node based on the type
		oXSL.load(strXSLTfile); 
		
		// Load the xml document 
		oXML.load(strXMLfile); 
		
		// Also check if we have optional params to insert
		if (strParam && strValue)
		{
			var oNode = oXSL.selectSingleNode("//xsl:param[@name='"+strParam+"']");
			if (oNode)
				oNode.text = strValue;
		}
		
		// Do the transform
		xslHTML = oXML.transformNode(oXSL); 
		oItem.innerHTML = xslHTML;
		
		//alert(xslHTML);
		return;
	}
	
	if (bNS7)
	{
		var xslStylesheet;
		var xsltProcessor = new XSLTProcessor();
		var xmlDoc;
		var xslHTML;
		
		// Load the xslt file
		var oXMLHTTPRequest = new XMLHttpRequest();
		oXMLHTTPRequest.overrideMimeType("text/xml");
		oXMLHTTPRequest.open("GET", strXSLTfile, false);
		oXMLHTTPRequest.send(null);
		
		xslStylesheet = oXMLHTTPRequest.responseXML;
		xsltProcessor.importStylesheet(xslStylesheet);
		
		// Load the xml file
		oXMLHTTPRequest = new XMLHttpRequest();
		oXMLHTTPRequest.open("GET", strXMLfile, false);
		oXMLHTTPRequest.send(null);

		// If there is the optional params, then we do this
		// Use the default (null) namespace should be ok
		if (strParam && strValue)
			xsltProcessor.setParameter(null, strParam, strValue);
		
		xmlDoc = oXMLHTTPRequest.responseXML;
		xslHTML = xsltProcessor.transformToFragment(xmlDoc, document);
		oItem.appendChild(xslHTML);
	
		//alert(oItem.innerHTML);
		return;
	}

	// Not supported browser!?!
	oItem.innerHTML = "<b>Sorry only Internet Explorer 5.5 SP1 or Netscape 7 and better are supported... Please upgrade your web browser:<br/><ul><li><a href='http://www.microsoft.com/windows/ie/downloads/default.mspx'>Internet Explorer</a></li><li><a href='http://channels.netscape.com/ns/browsers/download.jsp'>Netscape</a></li></ul></b>";
}
//-->
