/*############## AJAX PROCESSOR #################*/

function AjaxProcessor(customer){
  this.HTTPCode = 0;
  this.status   = 0;
  this.customer = customer;
  this.result   = null;
  this.ProgID   = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
}

// private
AjaxProcessor.prototype._getConnector = function(){
  try{
    return new XMLHttpRequest();
  }catch(e){
    for(var i=0;i<this.ProgID.length;i++){
      try{
        return new ActiveXObject(this.ProgID[i]);
      }catch(e){
        continue;
      }
    }
   return false;
  }
}

AjaxProcessor.prototype.stop   = function(){
  if(this.request && this.request.readyState!=4){this.request.abort();}
}

AjaxProcessor.prototype.start  = function(){
  var oReq;
  this.request = oReq = this._getConnector();
  if(!oReq){
    return false;
  }
  this.customer.sleep();
  var oReqCustomer = this.customer;
  var oReqProvider = this;

  oReq.onreadystatechange = function()
  {
    if(oReq.readyState==4 && oReq.status){
		oReqCustomer.wakeup(oReq.status,oReq.responseText);
    }
  };

  oReq.open(this.customer.getMethod(),this.customer.calculateUrl(),this.customer.async);
 if (   this.customer.getMethod() =="POST" ) { 
   oReq.setRequestHeader('Content-Type',  'application/x-www-form-urlencoded; charset=UTF-8'); 
  oReq.send(this.customer.body);
 } else
  oReq.send(null);

  return true;
}