var requestQue = new HttpRequestQue();
function HttpRequestQue()
{
	this.List = new Array();
	this.requestAddWork = false;
	
	this.add = function(http)
	{
		var index = this.List.length;
		this.List[index] = new Http(http.url, http.onreadyst, http.method, http.body, http.headers, http.sync);
		this.List[index].onreadyst = http.onreadyst;
		this.send();
	}
	
	this.send = function()
	{
		if(this.requestAddWork === false)
		{
			if(this.List.length>0)
			{
				this.requestAddWork = true;
				this.List[0].doRequest();
			}
		}
	}
	
	this.requExecuted = function()
	{
		var cacheList = new Array();
		for (var i = 0; i < (this.List.length - 1); i ++)
		{
			cacheList[i] = this.List[i+1];
		}
		this.List = cacheList;
		cacheList = null;
		this.requestAddWork = false;
		this.send();
	}
}
var request = null;
function Http(url, onreadyst, method, body, headers, sync)
{
	this.url = url;
	this.onreadyst = onreadyst || function(){};
	this.method = method || 'GET';
	this.body = body || null;
	this.headers = headers || false;
	this.sync = sync || true;
	this.abortReq = false;
	this.req = (window.XMLHttpRequest)
		?
		new XMLHttpRequest()
		:
		((window.ActiveXObject)
		?
		new ActiveXObject("Microsoft.XMLHTTP")
		:
		false
		);
	this.doRequest = function()
	{
		this.req.open(this.method,this.url,this.sync);
		if (this.headers)
		{
			for (var i = 0; i < this.headers.length; i += 2)
			{
				this.req.setRequestHeader(
					this.headers[i], this.headers[i+1]
				);
			}
		}
		this.req.onreadystatechange = this.onreadyst;
		this.req.send(this.body);
	}
}