/**
 * Author: Chris Wetherell
 * Client-side XML DOM management
 */
	function GetXMLViaHTTP(sURL) {
		try {
		  // For Mozilla
		  req = new XMLHttpRequest();
		  //req.overrideMimeType("text/xml");
		} catch (e) {
		  // For IE5+
		  req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		var cacheKiller = new Date().getTime();
		//alert(sURL)
		sURLUnique=sURL+"?"+cacheKiller;
		req.open("GET", sURLUnique,false);
		req.send(null);
		//alert(req.responseText);
		doc = req.responseXML;
		if (doc==null) alert("Error in GetXMLViaHTTP: Could not find file at '"+sURL+"'");
		return doc;
	}

/*
	function CreateXMLFromString(string) {
	  var xmlParser, xmlDocument;
	  try {
	    xmlParser = new DOMParser();
	    xmlDocument = xmlParser.parseFromString(string, "text/xml");
	    alert(xmlDocument)	 
	    return xmlDocument;
	  }
	  catch (e) {
	  	xmlDocument = new ActiveXObject("Msxml2.DOMDocument");
    	xmlDocument.async = false;
    	xmlDocument.loadXML(string);
    	return xmlDocument;
	  }
	}
	*/

	function CreateXMLFromString(string) {
		  var xmlParser, xmlDocument;
		  try {
			  	xmlDocument = new ActiveXObject("Msxml2.DOMDocument");
		    	xmlDocument.async = false;
		    	xmlDocument.loadXML(string);
		    	return xmlDocument;
		  }
		  catch (e) {
			    xmlParser = new DOMParser();
			    xmlDocument = xmlParser.parseFromString(string, "text/xml");
			  //  alert(xmlDocument)	 
			    return xmlDocument;

		  }
		}

	
	function TransformNodeToHTMLObject(objXML,objXSL) {
		var result = TransformNodeToFragment(objXML,objXSL);
		if (document.all) { //IE blows
			var tmp = document.createElement("div");
			tmp.setAttribute("id","tmp");
			document.body.appendChild(tmp);
			tmp.style.display="none";
			tmp.innerHTML=result.xml;
			tmp.setAttribute("id","");
			result = tmp.childNodes[0];
			tmp = null;
		}
		return result;
	}

	function TransformPathsToObject(strXMLPath,strXSLPath) {
			// Load XML source document
			var objXML = new ActiveXObject("Msxml2.DOMDocument");
			objXML.async = false;
			objXML.loadXML(strXMLPath);

			// Load XSLT stylesheet
			var objXSL = new ActiveXObject("Msxml2.DOMDocument");
			objXSL.async = false;
			objXSL.load(strXSLPath);
			return TransformNodeToObject(objXML,objXSL);
	}

	function TransformNodeToFragment(objXML,objXSL) {
		try {
			var xsltProcessor = new XSLTProcessor();
			xsltProcessor.importStylesheet(objXSL);
			var fragment = xsltProcessor.transformToFragment(objXML, document);
			return fragment;
		} catch(e) {
			// Create first resulting DOM document
			var result = new ActiveXObject("Msxml2.DOMDocument");
			result.async = false;
			// Perform transformation
			objXML.transformNodeToObject(objXSL, result);
			return result;
		}
	}

	function TransformNodeToDocumentObject(objXML,objXSL) {
		try {
			var xsltProcessor = new XSLTProcessor();
			xsltProcessor.importStylesheet(objXSL);
			var fragment = xsltProcessor.transformToDocument(objXML, document);
			return fragment;
		} catch(e) {
			// Create first resulting DOM document
			var result = new ActiveXObject("Msxml2.DOMDocument");
			result.async = false;
			// Perform transformation
			//alert(objXML)
			objXML.transformNodeToObject(objXSL, result);
			return result;
		}
	}


	/* Hey, Mozilla documents deserve ".xml" getters... */
	if (!document.all) {
		Node.prototype.__defineGetter__("xml", _Node_getXML);
	}
	function _Node_getXML() {
	    var objXMLSerializer = new XMLSerializer;
	    var strXML = objXMLSerializer.serializeToString(this);
	    return strXML;
	}
