Ajax=function(addrandomnumber, filetype)
{
	this.basedomain='http://'+location.hostname;
	this.filetype=(filetype!=undefined ? filetype : 'txt');
	this.addrandomnumber=(addrandomnumber!=undefined ? addrandomnumber : false);
	
	this.ajaxobj=false;
	if (window.ActiveXObject) // if IE
	{
		try{
			this.ajaxobj=new ActiveXObject("Msxml2.XMLHTTP");
		}catch (err)
		{
			try{
				this.ajaxobj=new ActiveXObject("Microsoft.XMLHTTP");
			}catch (err) {}
		}
	}
	else if (window.XMLHttpRequest) // if Mozilla, Safari etc
	{
		this.ajaxobj=new XMLHttpRequest();
		if (this.ajaxobj.overrideMimeType);
			this.ajaxobj.overrideMimeType(this.filetype=='xml' ? 'text/xml' : 'text/plain');
	}
}

Ajax.prototype.get=function(url, callbackfunc)
{
	if (this.addrandomnumber) // To stop IE caching
		var url=url+(url.indexOf('?')!= -1 ? '&' : '?')+"ts="+new Date().getTime();
	if (this.ajaxobj)
	{
		this.ajaxobj.onreadystatechange=callbackfunc;
		this.ajaxobj.open('GET', url, true);
		this.ajaxobj.send(null);
	}
}

Ajax.prototype.post=function(url, parameters, callbackfunc)
{
	if (this.ajaxobj)
	{
		this.ajaxobj.onreadystatechange = callbackfunc;
		this.ajaxobj.open('POST', url, true);
		this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.ajaxobj.setRequestHeader("Content-length", parameters.length);
		this.ajaxobj.setRequestHeader("Connection", "close");
		this.ajaxobj.send(parameters);
	}
}

Ajax.prototype.request=function(url, parameters, calltype, callbackfunc)
{
	if(calltype.toLowerCase()=='post')
		this.post(url, parameters, callbackfunc);
	else
		this.get(url+'?'+parameters, callbackfunc);
}

Ajax.prototype.ready=function()
{
	return (this.ajaxobj.readyState == 4);
}

Ajax.prototype.status=function()
{
	return (this.ajaxobj.status);
}

Ajax.prototype.response=function()
{
	return (this.filetype=='txt' ? this.ajaxobj.responseText : this.ajaxobj.responseXml);
}
