Ajax = extendClass (null,{
	_req:{},

	regObj:function(key){		this._req[key] = extendClass (null,{			key:key,
			xmlHttpReq:null,
			onLoading:function(){},
			onSuccess:function(){}
		});
		return this._req[key];
	},

	dropObj:function(key){delete(this._req[key]);},

	post:function(strURL, data) {
	    var date = new Date()
	    var key = '_'+date.getTime();
	    var self = this.regObj(key);
	    var actions = (arguments[2]||{});

	    if (window.XMLHttpRequest) self.xmlHttpReq = new XMLHttpRequest();
	    else if (window.ActiveXObject) self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    else throw new Error("There was a problem instantiating the XMLHttpRequest");

	    if (typeof actions.onLoading == 'function')self.onLoading = actions.onLoading;
	    if (typeof actions.onSuccess == 'function')self.onSuccess = actions.onSuccess;

	    self.xmlHttpReq.open('POST', strURL, true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    self.xmlHttpReq.onreadystatechange = function() {
	        if (self.xmlHttpReq.readyState == 1) {
	            self.onLoading();
	        }
	        if (self.xmlHttpReq.readyState == 4) {
	            self.onSuccess(self.xmlHttpReq);
	            setTimeout('Ajax.dropObj("'+self.key+'")',0);
	        }
	    };
	    self.xmlHttpReq.send(this.getquerystring(data));
	},

	getquerystring:function(data) {
        var qstr =[];
        for(var i in data)
	    qstr.push(encodeURIComponent(i)+'=' + encodeURIComponent(data[i].toString()));
	    return qstr.join('&');
	},

	get:function(strURL, data) {
	    var date = new Date()
	    var key = '_'+date.getTime();
	    var self = this.regObj(key);
	    var actions = (arguments[2]||{});

	    if (window.XMLHttpRequest) self.xmlHttpReq = new XMLHttpRequest();
	    else if (window.ActiveXObject) self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    else throw new Error("There was a problem instantiating the XMLHttpRequest");

	    if (typeof actions.onLoading == 'function')self.onLoading = actions.onLoading;
	    if (typeof actions.onSuccess == 'function')self.onSuccess = actions.onSuccess;

        var url = strURL+'?'+this.getquerystring(data);
	    self.xmlHttpReq.open('GET', url, true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    self.xmlHttpReq.onreadystatechange = function() {
	        if (self.xmlHttpReq.readyState == 1) {
	            self.onLoading();
	        }
	        if (self.xmlHttpReq.readyState == 4) {
	            self.onSuccess(self.xmlHttpReq);
	            setTimeout('Ajax.dropObj("'+self.key+'")',0);
	        }
	    }
	    self.xmlHttpReq.send(this.getquerystring(data));
	}
});



