function dexAjax() {

	//Declare and initialize the attributes
	this.url="";
	this.params="";
	this.method="GET";
	this.onSuccess=null;
	this.onError=function (msg) {
		alert(msg)
	}

}



dexAjax.prototype.doRequest=function() {

  //Check the parameters
  if (!this.url) {
    this.onError("There was no URL given. The request will be canceled.");
    return false;
  }

  if (!this.method) {
    this.method="GET";
  } else {
    this.method=this.method.toUpperCase();
  }

  //Make the access to the class for the readyStateHandler possible
  var _this = this;

  //Create XMLHttpRequest-Object
  var xmlHttpRequest=getXMLHttpRequest();
  if (!xmlHttpRequest) {
    alert("I couldn't create a XMLHttpRequest-Object.");
    return false;
  }

  //Switch case for each transfer method
  switch (this.method) {
    case "GET": xmlHttpRequest.open(this.method, this.url+"?"+this.params, true);
                xmlHttpRequest.onreadystatechange = readyStateHandler;
                xmlHttpRequest.send(null);
                break;
    case "POST": xmlHttpRequest.open(this.method, this.url, true);
                 xmlHttpRequest.onreadystatechange = readyStateHandler;
                 xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                 xmlHttpRequest.send(this.params);
                 break;
  }

  //Private Method for handling the received data
  function readyStateHandler() {
    if (xmlHttpRequest.readyState < 4) {
      return false;
    }
    if (xmlHttpRequest.status == 200 || xmlHttpRequest.status==304) {
      if (_this.onSuccess) {
        _this.onSuccess(xmlHttpRequest.responseText, xmlHttpRequest.responseXML);
      }
    } else {
      if (_this.onError) {
        _this.onError("["+xmlHttpRequest.status+" "+xmlHttpRequest.statusText+"] There was an error with the data transfer. Please try again in a few minutes.");
      }
    }
  }
}



//Returns a browser-based XMLHttpRequest-Object
function getXMLHttpRequest() {

  if (window.XMLHttpRequest) {
    //XMLHttpRequest for Firefox, Opera, Safari, ...
    return new XMLHttpRequest();
  } else
  if (window.ActiveXObject) {
    try {
      //XMLHTTP (new) for Internet Explorer
      return new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        //XMLHTTP (old) for Internet Explorer
        return new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        return null;
      }
    }
  }
  return false;

}


