function CAjaxRequest(responseHandler, responseParam, url, method, allowCache)
{
this.responseHandler = responseHandler;
this.responseParam = responseParam;
this.url = allowCache||!window.g_browser ? url : g_browser.MakeNocacheUrl(url);
this.method = method ? method : "GET";
}
function CAjaxQueue(objName, replacePageOnError)
{
this.broken = false;
this.IsReady = function() {return !this.m_obj;}
this.Send = function(responseHandler, responseParam, url, method, allowCache)
{
if (!url)
return false;
this.m_queue.push(new CAjaxRequest(responseHandler, responseParam, url, method, allowCache));
if (this.IsReady())
return this.p_Send();
else 
this.m_timer = setTimeout(this.m_myName+".p_ForceSend()", 30000);
return true;
}
this.p_Send = function()
{
if (this.m_queue.length == 0)
return true;
try{this.m_obj=new XMLHttpRequest()}catch(e){try{this.m_obj=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{this.m_obj=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){this.broken=false;return false;}}}
var req = this.m_queue[0];
if (this.m_obj)
{
this.lastUrl = req.url;
this.m_obj.onreadystatechange = new Function("return "+this.m_myName+".p_OnStateChange()");
if (req.method == "GET")
{
this.m_obj.open("GET", req.url, true);
try{this.m_obj.send(null);}catch(e){}
}
else
{
var parts = req.url.split('?');
this.m_obj.open("POST", parts[0], true);
this.m_obj.setRequestHeader("Connection", "close");
this.m_obj.setRequestHeader("Content-Length", parts[1].length);
this.m_obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
try{this.m_obj.send(parts[1]);}catch(e){}
}
}
else if (this.m_replacePageOnError)
window.open(req.url, '_self');
else
return false;
return true;
}
this.p_ForceSend = function()
{
if (this.m_timer)
{
clearTimeout(this.m_timer);
this.m_timer = null;
}
delete this.m_obj;
this.m_queue.shift();
this.p_Send(); 
}
this.p_OnStateChange = function(state)
{
if (this.m_obj.readyState==4) 
{
var req = this.m_queue[0];
if (req.responseHandler)
{
req.responseHandler(this.m_obj.responseText, req.responseParam);
this.p_ForceSend();
}
}
}
this.lastUrl = null;
this.m_queue = new Array();
this.m_timer = 0;
this.m_myName = objName;
this.m_obj = null;
this.m_replacePageOnError = replacePageOnError;
}


