
ReadyState={
Uninitialized:0,
Loading:1,
Loaded:2,
Interactive:3,
Complete:4};
ActionType={
POST:"POST",
GET:"GET",
HEAD:"HEAD"}
function AJAX(path){
this.m_strPath=path;
this.m_objXML=__GetXMLHttpObj();
this.m_strAction=ActionType.GET;
this.m_pfnCallBackFun=null;
this.m_objParam=null;
this.m_strUrlParam="";
this.m_objXML.onreadystatechange=(function(obj){
return function(){
if(obj.m_objXML.readyState==ReadyState.Complete)(obj.m_pfnCallBackFun)(obj);};})(this);
this.SelectNodes=function(cXPathString,xNode){
return SelectNodes(cXPathString,xNode)}
this.SelectSingleNode=function(cXPathString,xNode){
return SelectSingleNode(cXPathString,xNode)}
this.SetCustomParam=function(objParam){
this.m_objParam=objParam;}
this.GetCustomParam=function(){
return this.m_objParam;}
this.AddUrlParameter=function(strName,strValue){
if(this.m_strUrlParam.length>0)
this.m_strUrlParam+="&";
this.m_strUrlParam+=__URLEncode(strName.toString())+"="+__URLEncode(strValue.toString());}
this.ClearUrlParameters=function(){
this.m_strUrlParam="";}
this.SetCallbackFun=function(pfnCallback){
this.m_pfnCallBackFun=pfnCallback;};
this.SetAction=function(emActionType){
this.m_strAction=emActionType;};
this.Send=function(){
try{
this.AddUrlParameter("Now",new Date().toString());
var strUrl=this.m_strPath;
if(this.m_strUrlParam.length>0){
strUrl=strUrl+((strUrl.indexOf("?")<0)?"?":"&");
strUrl+=this.m_strUrlParam;}
this.m_objXML.open(this.m_strAction,strUrl,true);
this.m_objXML.send(null);
return true;}
catch(e){
alert(e);
return false;}};
this.GetXmlDoc=function(){
if(this.m_objXML.responseXML==null){
//alert("Error: the response does not contain a XML document!");
return null;}
return this.m_objXML.responseXML;};
this.GetResponse=function(){
if(this.m_objXML.responseText==null){
alert("Error: the response is null!");
return null;}
return this.m_objXML.responseText;};}
function __GetXMLHttpObj(){
if(typeof(XMLHttpRequest)!='undefined')
return new XMLHttpRequest();
var aryNames=['Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.4.0',
'Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP'];
for(var i=0;i<aryNames.length;i++){
try{
return new ActiveXObject(aryNames[i]);}
catch(e){}}
alert("Error: can not create XML Http Object!");
return null;}
function __URLEncode(strURL){
var m="",sp="!'()*-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~";
for(var i=0;i<strURL.length;i++){
if(sp.indexOf(strURL.charAt(i))!=-1){
m+=strURL.charAt(i)}
else{
var n=strURL.charCodeAt(i)
var t="0"+n.toString(8)
if(n>0x7ff)
m+=("%"+(224+parseInt(t.slice(-6,-4),8)).toString(16)+"%"+(128+parseInt(t.slice(-4,-2),8)).toString(16)+"%"+(128+parseInt(t.slice(-2),8)).toString(16)).toUpperCase()
else if(n>0x7f)
m+=("%"+(192+parseInt(t.slice(-4,-2),8)).toString(16)+"%"+(128+parseInt(t.slice(-2),8)).toString(16)).toUpperCase()
else if(n>0x3f)
m+=("%"+(64+parseInt(t.slice(-2),8)).toString(16)).toUpperCase()
else if(n>0xf)
m+=("%"+n.toString(16)).toUpperCase()
else
m+=("%"+"0"+n.toString(16)).toUpperCase()}}
return m;}