function getAjaxProvider(){
    if (window.XMLHttpRequest){
        return new XMLHttpRequest();              
    }else{
        return new ActiveXObject("Microsoft.XMLHTTP");
    }   
}
function ajaxObject(url, callbackFunction, imgLoader, params, postMethod){
    var that = this;      
    this.updating = false;
    that.ImgLoader = imgLoader
    that.Params = params
    that.PostMethod = postMethod    
    if (that.ImgLoader){
        document.getElementById(imgLoader).style.display = '';
    }    
    this.abort = function(){
        if (that.updating){
            that.updating = false;
            that.AJAX.abort();
            that.AJAX = null;
        }
    }
    this.update = function(postMethod){ 
        if (that.updating){ return false; }
        that.AJAX = null;                          
        that.AJAX = getAjaxProvider();                                
        if (that.AJAX==null) {                             
            return false;                               
        }else{
            that.AJAX.onreadystatechange = function() {  
                if (that.AJAX.readyState==4) {             
                    that.updating=false;                
                    if (that.ImgLoader){
                        document.getElementById(imgLoader).style.display = 'none';
                    }                                        
                    that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
                    that.AJAX=null;                                         
                    that = null;
                }                                                      
            }                                                                    
            if (/post/i.test(postMethod)) {
                var uri=urlCall;//+'?'+that.updating.getTime();
                that.AJAX.open("POST", uri, true);
                that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                that.AJAX.send(that.PostMethod.join('&'));
            } else {
                var uri=urlCall;//+'?'+passData+'&timestamp='+(that.updating.getTime()); 
                that.AJAX.open("GET", uri, true);                             
                that.AJAX.send(null);                                         
            }              
            return true;                                             
        }                                                                           
    }
    var urlCall = url;        
    this.callback = callbackFunction || function () { };
    this.update();
}




/*

Any help given gratefully recieved.
Dan.

XMLHttp = function() {
  self = this;
  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) {}
    }
  }
  throw new Error('XMLHttp (AJAX) not supported');
}

XMLHttp.prototype.get = function(url) {
  self.open('GET', url, true);
  self.onreadystatechange = function() {
     self.processRequest();}
  self.send(null);
}

XMLHttp.prototype.processRequest = function() {
  if (self.readyState == 4) {
    if (self.status != 200) {
      self.resp = 'Error : Status '+this.status+' returned.';
    } else {
      if (cType == 'text/xml') {
    self.resp = 'xml';
      } else if (cType == 'text/plain') {
    self.resp = 'text';
      } else {
    self.resp = 'unknown content type';
      }
      this.response();
    }
  }
}

ajaxObj = XMLHttp();
ajaxObj.get('myrequest.php');

ajaxObj2 = XMLHttp();
ajaxObj2.get('myrequest.php');

ajaxObj.response = function() {
  if (self.resp == 'xml') {
    alert(self.responseXML);
  } else if (self.resp == 'text') {
    alert(self.responseText);
  } else {
    alert(self.resp);
  }
}
ajaxObj2.response = function() {
  if (self.resp == 'xml') {
    alert(self.responseXML);
  } else if (self.resp == 'text') {
    alert(self.responseText);
  } else {
    alert(self.resp);
  }
}*/
