var xslDoc;
var xmlDoc;
var xslTemplate;
var xslProcessor;
var xslOutput;
var xslOutputTop;
var xslOutputWidth;
var xslOutputHeight;
var OutputNeedReset;

function loadXMLDoc(XMLPath, XSLPath, outputObj) {
	// code for IE
	xslOutput = getObject(outputObj);
	if (xslOutput != null) {
		xslOutputTop = getObject(outputObj+"top");
		if (xslOutputTop != null) 
			xslOutputTop.style.display = "";
		xslOutputTop = getObject(outputObj+"brdr");
		if (xslOutputTop != null) 
			xslOutputTop.style.display = "";
		xslOutput.style.display = "";
		xslOutputWidth = xslOutput.style.width;
		xslOutputHeight = xslOutput.style.height;
		xslOutput.style.height='20px';
		xslOutput.style.width='150px';
		xslOutput.innerHTML='<img src="../newhomepagegraphics/smallbusy.gif">'
		xslOutput.style.display='';
		outputNeedReset=true;
		if (window.ActiveXObject) {
			xslDoc=new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
			xslDoc.async=false;
			xslDoc.load(XSLPath);
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.ondataavailable = formatPartList;
			xmlDoc.onreadystatechange = finishPartList;
			xmlDoc.async=true;
			xslTemplate = new ActiveXObject("MSXML2.XSLTemplate");
			xslTemplate.stylesheet = xslDoc;
			xslProcessor = xslTemplate.createProcessor();
			xslProcessor.input = xmlDoc;
			xmlDoc.load(XMLPath);
		}
		// code for Mozilla, Firefox, Opera, etc.
		else if (document.implementation && document.implementation.createDocument) {
		  xslDoc=document.implementation.createDocument("","xsldoco",null);
		  xslProcessor = new XSLTProcessor();
		  xslDoc.async=false;
		  xslDoc.load(XSLPath);
		  try {xslProcessor.importStylesheet(xslDoc);} catch (e) {alert (e)}
		  xmlDoc=document.implementation.createDocument("","xmldoco",null);
		  xmlDoc.addEventListener("load",formatPartList,false);
		  xmlDoc.async=true;
		  xmlDoc.load(XMLPath);
		  }
		else
		  alert('Your browser cannot handle this script');
	} else 
		alert ('There is no target output found on this page.');
}

function formatPartList (){
	if (outputNeedReset) {
		xslOutput.innerHTML='';
		xslOutput.style.width=xslOutputWidth;
		xslOutput.style.height=xslOutputHeight;
		outputNeedReset=false;
		}
	if (xmlDoc.length==0) xslOutput.style.display='none';
	if (window.ActiveXObject) {
		xslProcessor.transform();
		xslOutput.innerHTML += xslProcessor.output;
	} else {
		var newDocument = xslProcessor.transformToFragment(xmlDoc,document);
		xslOutput.appendChild(newDocument);
	}
}

function finishPartList () {
	if (xmlDoc.readyState == 4) 
		formatPartList()
}

function closeTable(objName) {
	xslOutputTop = getObject(objName+"brdr");
	if (xslOutputTop != null) 
		xslOutputTop.style.display = "none";
	xslOutput = getObject(objName+"top");
	if (xslOutput != null) 
		xslOutput.style.display = "none";
	xslOutput = getObject(objName);
	if (xslOutput != null) 
		xslOutput.style.display = "none";
}

function getObject( obj ) {
  if ( document.getElementById ) {
    obj = document.getElementById( obj );
  } else if ( document.all ) {
    obj = document.all.item( obj );
  } else {
    obj = null;
  }
  return obj;
}

