function AdfXMLRequest() {
  this.Init();
}
AdfObject.createSubclass(AdfXMLRequest);
AdfXMLRequest.UNINITIALIZED = 0;
AdfXMLRequest.LOADING = 1;
AdfXMLRequest.LOADED = 2;
AdfXMLRequest.INTERACTIVE = 3;
AdfXMLRequest.COMPLETED = 4;
AdfXMLRequest._CHECKPOINT = AdfCheckpoint.getCheckpoint("send", "postback");
AdfXMLRequest._CHECKPOINT.setDescription("A measurement of how long is spend processing an XMLHttpRequest");
AdfXMLRequest._startCheckpoint = function() {
  if (AdfXMLRequest._checkpointId == undefined) {
    AdfXMLRequest._checkpointId = AdfXMLRequest._CHECKPOINT.start();
  }
};
AdfXMLRequest._stopCheckpoint = function() {
  if (AdfXMLRequest._checkpointId != undefined) {
    AdfXMLRequest._CHECKPOINT.stop(AdfXMLRequest._checkpointId);
    AdfXMLRequest._checkpointId = undefined;
  }
};
AdfXMLRequest.prototype.Init = function() {
  AdfXMLRequest.superclass.Init.call(this);
  this.isSynchronous = false;
  this.callback = null;
  this._state = AdfXMLRequest.UNINITIALIZED;
  this.headers = new Object;
  this.xmlhttp = AdfAgent.AGENT.createXMLHttpRequest();
  if (!this.xmlhttp) {
    var xmlhttpWarningMessage = AdfPage.PAGE.getLookAndFeel().getTranslatedString("af_document.XMLHTTP_UNSUPPORTED");
    alert(xmlhttpWarningMessage);
  }
};
AdfXMLRequest.prototype.toString = function() {
  return AdfXMLRequest.superclass.toString.call(this) + " completionState:" + this.getCompletionState();
};
AdfXMLRequest.prototype.setSynchronous = function(isSynch) {
  this.isSynchronous = isSynch;
};
AdfXMLRequest.prototype.setCallback = function(_callback) {
  this.callback = _callback;
};
AdfXMLRequest.prototype.addEventListener = function(event, listener) {
  if (this.xmlhttp.upload) {
    this.xmlhttp.upload.addEventListener(event, listener, false);
  }
};
AdfXMLRequest.prototype.getCompletionState = function() {
  return this._state;
};
AdfXMLRequest.prototype.getStatus = function() {
  return this.xmlhttp.status;
};
AdfXMLRequest.prototype.getResponseXML = function() {
  return this.xmlhttp.responseXML;
};
AdfXMLRequest.prototype.getResponseText = function() {
  return this.xmlhttp.responseText;
};
AdfXMLRequest.prototype.send = function(url, content, ommitAdfRichMessage) {
  var xmlhttp = this.xmlhttp;
  if (!this.isSynchronous && this.callback) {
    var cb = function anonymous() {
      arguments.callee.obj.__onReadyStateChange();
    };
    cb["obj"] = this;
    xmlhttp.onreadystatechange = cb;
  }
  AdfXMLRequest._startCheckpoint();
  var method = content !== null && content !== undefined ? "POST" : "GET";
  xmlhttp.open(method, url, !this.isSynchronous);
  for (var name in this.headers) {
    xmlhttp.setRequestHeader(name, this.headers[name]);
  }
  if (!ommitAdfRichMessage) {
    xmlhttp.setRequestHeader("Adf-Rich-Message", "true");
  }
  xmlhttp.send(content);
  if (this.isSynchronous) {
    this["__onReadyStateChange"]();
  }
};
AdfXMLRequest.prototype.abort = function() {
  var xmlhttp = this.xmlhttp;
  if (xmlhttp) {
    xmlhttp.abort();
  }
};
AdfXMLRequest.prototype.getResponseHeader = function(name) {
  return this.xmlhttp.getResponseHeader(name);
};
AdfXMLRequest.prototype.getAllResponseHeaders = function() {
  return this.xmlhttp.getAllResponseHeaders();
};
AdfXMLRequest.prototype.setRequestHeader = function(name, value) {
  this.headers[name] = value;
};
AdfXMLRequest.prototype["__onReadyStateChange"] = function() {
  this._state = this.xmlhttp.readyState;
  if (this._state == AdfXMLRequest.COMPLETED) {
    AdfXMLRequest._stopCheckpoint();
    if (AdfPage.PAGE.isUserActivityMonitoringOn()) {
      if (this.xmlhttp.responseXML) {
        AdfUserActivityInfo.setResponseReceivedTime();
      }
    }
  }
  if (this.callback) {
    this.callback(this);
  }
};
AdfXMLRequest.prototype.cleanup = function() {
  this.callback = null;
  delete this.headers;
  delete this.xmlhttp;
};
