
//Xsl转Html
function GenXsl2Html(xslName,xmlText)
{
    var xmlDom=new ActiveXObject("Microsoft.XMLDOM");//createXmlDom();
    xmlDom.async=false;
    xmlDom.loadXML(xmlText);
    var xslDom=new ActiveXObject("Microsoft.XMLDOM");//createXmlDom();
    xslDom.async=false;
    xslDom.load(xslName);
   // var ii;
    try
    {  
        return xmlDom.transformNode(xslDom);
    }
    catch(e)
    {
        alert("Fatal error occurs! Xsl transform Failed!");
        return false;
    }
}
//xmlText转xml
function GenXmlTextToXml(xmlText)
{
    var xmlDom=new ActiveXObject("Microsoft.XMLDOM");//createXmlDom();
    xmlDom.async=false;
    if(xmlDom.loadXML(xmlText)==false)
        xmlDom="";
    return xmlDom;
}

//创建XML
function createXmlDom()
{
    var arrSignatures=["MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","Microsoft.XmlDom"];
    
    for(var i=0;i<arrSignatures.length;i++)
    {
        try
        {
            var oXmlDom=new ActiveXObject(arrSignatures[i]);
            return oXmlDom;
        }
        catch(oError)
        {
        }
    }
    throw new Error("MSXML is not installed on your system.");
}

//XmlRequest
 var xmlHttpObj="";
function GenSendAyncXmlRequest(data2Send,svrUrl)
{   
    //var strReture="";
	//var dynaXmlhttp =new DynaXmlHttp();
	
    xmlHttpObj = createXmlHttp();
	GetAjaxDataByPost(data2Send,svrUrl,"GetReturnAjaxDate(obj)");

}


this.requestParams = new Object();

function GetAjaxDataByPost(data2Send,url,fun)
{
	
	if(xmlHttpObj == null)
	{
		alert("Please set a xmlhttp object first");
		return false;
	}
	if(!xmlHttpObj)
	{
		alert("Xmlhttp object init failed");
		return false;
	}

		
	for(var attr in data2Send)
	{
		this.requestParams[attr] = data2Send[attr];
	}	
xmlHttpObj.onreadystatechange = function(){
    if(xmlHttpObj.readyState == 4){
		if (xmlHttpObj.status ==200){
		    obj = xmlHttpObj.responseText;
			eval(fun);
		     }
		else{
			alert("读取文件出错,错误号为 [" + xmlHttpObj.status  + "]");
		}
    }
   }
		
		
		
  // }
	this.xmlHttpObj.open("post",url,true);
	
	//this.xmlhttpObj.setRequestHeader("Content-Type","text/xml;charset=GB2312");
	//if(this.method.toLowerCase() == "post")
	//{
      this.xmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	//}
	this.xmlHttpObj.setRequestHeader("If-Modified-Since","0");
	this.xmlHttpObj.setRequestHeader("Connection","close");
	var params = "";
	for(var attr in this.requestParams) 
	{
		params += "&"+attr+"=";
		params += encodeURIComponent(this.requestParams[attr]);
	}
	params = params.substr(1);
	this.xmlHttpObj.send(params);
	//return true;
}

