XMLHttp = function(){
}

XMLHttp.prototype.GetXmlHttpRequest = function(){  
  if (typeof(XMLHttpRequest) != 'undefined'){
    return new XMLHttpRequest();
  }
  else if (window.ActiveXObject) {
    var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp", "MSXML2.XmlHttp.3.0",  "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.5.0"];
    for (var i = avers.length -1; i >= 0; i--) {
      try{httpObj = new ActiveXObject(avers[i]); 
        return httpObj;
      } catch(e) {}
    }
  }
  return null;    
}

XMLHttp.prototype.SendAsync = function(url, action, onFault, onWait){
  var xmlHttpReq = this.GetXmlHttpRequest();  
  if (xmlHttpReq.readyState == 4 || xmlHttpReq.readyState == 0){
    xmlHttpReq.onreadystatechange = function(){
      if (xmlHttpReq.readyState == 4){
        if (xmlHttpReq.status == 200){
          if (action != null){
            //var xmlResponse = xmlHttpReq.responseXML;
            //var responseText = xmlHttpReq.responseText;
            // obtain the document element (the root element) of the XML structure
            //var xmlDocumentElement = xmlResponse.documentElement;
            // get the text message, which is in the first child of
            // the the document element
            //var response = xmlDocumentElement.firstChild;
            action(xmlHttpReq);
          }
        }else{
          if (onFault != null){
            onFault(xmlHttpReq.statusText);
          }
        }    
      }else{
        if (onWait != null){
          onWait(xmlHttpReq.readyState);
        }
      }
    } 
    xmlHttpReq.open("GET", url, true);
    xmlHttpReq.send(null);    
  }else{
    alert("XMLHTTP BUSY!");
  }  
}