/*
*****************************************
Name: XMLClass
Author: Sergey Valunin, regensv@gmail.com
Created date: 08.01.2006
*****************************************
*/

function LoadXSL(xslFile){
	if(window.ActiveXObject){
		this.xsl = new ActiveXObject("Microsoft.XMLDOM");
		this.xsl.async = false;
		this.xsl.load(xslFile);
	}
	else if(document.implementation && document.implementation.createDocument){
		var myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", xslFile, false);
		myXMLHTTPRequest.send(null);
		this.xsl = myXMLHTTPRequest.responseXML;
		
		this.xsltProcessor = new XSLTProcessor();
		this.xsltProcessor.importStylesheet(this.xsl);
  	}
}

function LoadXML(xmlFile){
	if(window.ActiveXObject){
		this.xml = new ActiveXObject("Microsoft.XMLDOM");
		this.xml.async = false;
		this.xml.load(xmlFile);
	}
	else if(document.implementation && document.implementation.createDocument){
		//this.xml = document.implementation.createDocument("", "", null);
  	//this.xml.load(this.xmlFile);
  		
  	var myXMLHTTPRequest = new XMLHttpRequest();
		myXMLHTTPRequest.open("GET", xmlFile, false);
		myXMLHTTPRequest.send(null);
		this.xml = myXMLHTTPRequest.responseXML;
  	}
}

function Transform(resultID){
	if(window.ActiveXObject){
		document.getElementById(resultID).innerHTML = this.xml.transformNode(this.xsl);
	}
	else if(document.implementation && document.implementation.createDocument){
		var fragment = this.xsltProcessor.transformToFragment(this.xml, document);
		document.getElementById(resultID).innerHTML = "";
		document.getElementById(resultID).appendChild(fragment);
	}
}

function XMLClass(){
	this.LoadXSL = LoadXSL;
	this.LoadXML = LoadXML;
	this.Transform = Transform;
}
