Object.extend = function(destination, source) {
  for (var property in source) {
    destination[property] = source[property];
  }
  return destination;
}

function AjaxRequest(sUrl,oOptions,pRefObj){
  var pRefObj  = pRefObj || window;
  this.Options = {
    method:'GET',
    params:'',
    async:true

  };
  Object.extend(this.Options,oOptions || {});
  this.Url = sUrl;
  if(this.Options.method.toUpperCase()=='GET' && this.Options.params!=''){
    if(this.Url.indexOf('?')!=-1)
      this.Url += "&"+this.Options.params;
    else
      this.Url += "?"+this.Options.params;
  }
  this.onStateChange = function(){
    if(pRefObj.xmlReq.readyState == 4){
      if(pRefObj.xmlReq.status == 200 || pRefObj.xmlReq.status == 304){
        if(pRefObj.xmlReq.responseText==""){
          pRefObj.onAjaxError();
        }else{
          pRefObj.onAjaxSuccess();
        }
      }else{
        pRefObj.onAjaxError();
      }
    }
  };
  var xmlRequest = false;
  try{
    xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
    try{
      xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(e){
      xmlRequest = false;
    }
  }
  if(!xmlRequest && typeof(XMLHttpRequest)!='undefined') {
    xmlRequest = new XMLHttpRequest();
  }
  if(xmlRequest){
    pRefObj.xmlReq = xmlRequest;
    pRefObj.xmlReq.open(this.Options.method,this.Url,this.Options.async);
    pRefObj.xmlReq.onreadystatechange = this.onStateChange;
    if(this.Options.method.toUpperCase()=='GET'){
      pRefObj.xmlReq.send(null);
    }else{
      pRefObj.xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      pRefObj.xmlReq.send(this.Options.params);
    }
  }
}