function Ajax() {
}

function Ajax(url, params) {
    this.url 			    = url;
	this.params 		    = params;
}

Ajax.prototype.getData = function(method) {

    var me = this;
    this.http=Ajax.GetXmlHttpObject();

    if (this.http==null) {
      alert ("Your browser does not support AJAX!");
      return;
    }

    this.http.onreadystatechange = function() {
        Ajax.handler(me);
    }

    if(method=="POST") {

        this.http.open("POST",this.url,true);
        this.http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        this.http.setRequestHeader("Content-length", this.params.length);
        this.http.setRequestHeader("Connection", "close");
        this.http.send(this.params);

    } else if (method=="GET") {
        this.http.open("GET",this.url + "?" + this.params,true);
		alert(this.url + "?" + this.params);
        this.http.send(null);

    }
}

Ajax.prototype.get = function() {
    this.getData("GET");
}

Ajax.prototype.post = function() {
    this.getData("POST");
}

Ajax.prototype.callback = function() {
};

Ajax.handler = function(o) {
    var obj = o;

    if (obj.http.readyState == 4) {
        if(obj.http.status == 200) {

            obj.txt				= obj.http.responseText;
            obj.xml 			= obj.http.responseXML;
            obj.readyState 		= obj.http.readyState;
            obj.status	 		= obj.http.status;
            obj.statusText		= obj.http.statusText;
            obj.headers 		= obj.http.getAllResponseHeaders();

            obj.callback();

        } else {

            alert("There was a problem retrieving the XML data:\n" + obj.http.statusText);
            return;

        }
    }
}

Ajax.GetXmlHttpObject = function() {
    var xmlHttpObj=null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttpObj=new XMLHttpRequest();

    } catch (e) {
        // Internet Explorer
        try {
            xmlHttpObj=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            xmlHttpObj=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttpObj;
}




