try {
var AJaX = function (url, handler) {
  this._handler = handler || null;
  this._url = url;
  this._http_method = "GET";
  AJaX.prototype._instances[this._url] = this;
};

AJaX.prototype['_instances'] = {}; 
AJaX.prototype['get'] = function (id) {
  return AJaX.prototype._instances[id];
}

AJaX.prototype.send = function (data) {
  if (! this._handler) throw ('You have not set a handler for this AJaX object');
  /* NOTE: (bc-20050927) - This must be done each time for IE. Rather than a single object created in the constructor method */
  this._req = (window.XMLHttpRequest)
    ? new XMLHttpRequest()
    : (window.ActiveXObject)
      ? new ActiveXObject("Microsoft.XMLHTTP")
      : alert('AJaX not supported');
  if(this._req) {
    this._req.onreadystatechange = this._handler;
    this._req.open(this._http_method, this._url+(this._http_method == "GET" ? '?'+data : ''), true);
    this._req.send((this._http_method == "POST" ? data : null));
  }
};

AJaX.prototype.is_ready = function () {
  // only if req shows "loaded"
  if (this._req.readyState == 4) {
      // only if "OK"
      if (this._req.status == 200) {
          return 1
      } else {
          alert("There was a problem retrieving the XML data:\n" +  this._req.statusText);
      }
  }
  return 0;
};

AJaX.prototype.XMLData = function () {
  if (this._req) {
    if (this._req.responseXML) {
      return this._req.responseXML;
    }
    else {
      alert('No XML Data. Perhaps XML file is not well formed.');
    }
  }
  return;
};


AJaX.prototype.abort = function () {
  if(this._req) {
    this._req.abort();
  }
};


}
catch (error) {
  alert('Error in AJax: '+error);
}
