function Ajax(setURL, setID, setLoadID, parentObj, setResponse, setSendData, getOrPost)
{
  this.url = setURL;
  this.id = setID;
  this.xmlHttp = null;
  this.loadID = setLoadID;
  this.parentObj = parentObj;
  this.response = setResponse;
  this.sendData = setSendData;
  this.content = "not loaded yet";
  var that = this;
  
  // When the page is loaded this function will print the information and call getPage() ones more.
  this.status = function()
  {
    if (that.xmlHttp.readyState==1)
    {
      document.getElementById(that.loadID).className="status statusLoading";
    }
    else if (that.xmlHttp.readyState==4)
    {
      if(that.xmlHttp.status == 200 || that.xmlHttp.status == 304)
      {
        that.content=that.xmlHttp[that.response];
        document.getElementById(that.loadID).className="status statusIdle";
      }
      else
      {
        that.content=null;
        document.getElementById(that.loadID).className="status statusError";
      }
      parentObj.loaded();
    }
  };
  
  this.postStatus = function()
  {
    if (that.xmlHttp.readyState==1)
    {
      document.getElementById(that.loadID).className="status statusLoading";
    }
    else if (that.xmlHttp.readyState==4)
    {
      if(that.xmlHttp.status == 200 || that.xmlHttp.status == 304)
      {
        that.content=that.xmlHttp[that.response];
        document.getElementById(that.loadID).className="status statusIdle";
      }
      else
      {
        that.content=null;
        document.getElementById(that.loadID).className="status statusError";
      }
      parentObj.loaded();
    }
  };
  
  if(getOrPost == "get")
  {
    this.getPage();
  }
  else if(getOrPost == "post")
  {
    this.postPage();
  }
}

// This function loads a page and gets the information from it.
Ajax.prototype.getPage=function()
{
  this.xmlHttp = this.HttpObject();
  // First we check so the browser suports Ajax
  if (this.xmlHttp == null)
  {
    alert ("Your browser is out of date\nPlease download a newer version for this site to work properly\n\nWe recommend www.getfirefox.com.");
    document.getElementById(this.loadID).className="statusError";
  }
  this.xmlHttp.onreadystatechange=this.status;
  this.xmlHttp.open("GET",this.url+"&rand="+Math.random(),true);
  this.xmlHttp.send(null);
}

Ajax.prototype.postPage=function()
{
  this.xmlHttp = this.HttpObject();
  // First we check so the browser suports Ajax
  if (this.xmlHttp == null)
  {
    alert ("Your browser is out of date\nPlease download a newer version for this site to work properly\n\nWe recommend www.getfirefox.com.");
    document.getElementById(this.loadID).className="statusError";
  }
  
  this.xmlHttp.onreadystatechange=this.postStatus;
  
  this.xmlHttp.open("POST",this.url,true);
  
  //Send the proper header information along with the request
  this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  this.xmlHttp.setRequestHeader("Content-length", this.sendData.length);
  this.xmlHttp.setRequestHeader("Connection", "close");
  
  this.xmlHttp.send(this.sendData);
}


Ajax.prototype.HttpObject=function()
{
  var xmlHttp = null;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch (e)
  {
    // Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}
