var req=null;

function http()
{
	this.init();

	return this.http ?this :null;
}

http.prototype.init=function()
{
	this.http=null;	

	if(window.ActiveXObject)
	{
		try { this.http=new ActiveXObject("Microsoft.XMLHTTP") } catch (e) {}
		if(!this.http) try { this.http=new ActiveXObject("Msxml2.XMLHTTP") } catch (e) {}
	}
	else if(window.XMLHttpRequest)
	{
		try { this.http=new XMLHttpRequest() } catch(e) {}
	}

	this.onSuccess=function(){};
	this.onError=function(){};
	this.onReady=function(){};
}

http.prototype.runRequest=function(url,func,id)
{
	if(this.http)
	{
		req=this;
		this.http.onreadystatechange=httpState;		
		this.action=func;
		this.id=id;

		this.http.open("GET",url+'&ajs=1',true);
		this.http.setRequestHeader("Cache-Control", "no-cache");
		this.http.setRequestHeader("Pragma", "no-cache");
		this.http.send(null);
	}
	else
	{
		document.location=url;
	}
}

function httpState()
{
	req.onReady(req.http.readyState);

	if(req.http.readyState==4)
	{
		if(req.http.status==200)
		{
			req.onSuccess();
		}
		else
		{
			req.onError();
		}

		req=null;
	}
}

