framework.http = {
_httpObjectsArray:new Object(),
_httpResultsArray:new Object(),
loadUrl:function(name, url, querystring, callbackSuccess, callbackFailure, timeout, redirectURL)
{
	if ((typeof(name) != framework.DataType.STRING) || (framework.util.isUndefinedOrNull(name)) || 
		(typeof(url) != framework.DataType.STRING) || (framework.util.isUndefinedOrNull(url)) ||
		(typeof(querystring) != framework.DataType.STRING) || (framework.util.isUndefinedOrNull(querystring)) ||
		(typeof(callbackSuccess) != framework.DataType.STRING) || (framework.util.isUndefinedOrNull(callbackSuccess)) ||
		(typeof(callbackFailure) != framework.DataType.STRING) || (framework.util.isUndefinedOrNull(callbackFailure)) ||
		(typeof(timeout) != framework.DataType.NUMBER) || (framework.util.isUndefinedOrNull(timeout)) ||
		((typeof(redirectURL) != framework.DataType.STRING) && (!framework.util.isUndefinedOrNull(redirectURL))))
	{
		return framework.Status.INVALID_ARGUMENT_VALUE;
	}
	if (framework.util.isEmpty(name) || framework.util.isEmpty(url) || (framework.util.isEmpty(redirectURL) && (typeof(redirectURL) == framework.DataType.STRING)))
	{
		return framework.Status.INVALID_ARGUMENT_VALUE;
	}	
	querystring = querystring + framework.Separator.AMPERSAND + framework.HttpConstants.TIMESTAMP + framework.Separator.EQUALS + framework.http._getDate();
	callbackSuccess = callbackSuccess + "('" + name + "')";
	callbackFailure = callbackFailure + "('" + name + "')";
	framework.http._executeHttpCall(name, url, querystring, callbackSuccess, callbackFailure, timeout, redirectURL);
	return framework.Status.SUCCESS;	
},
getHttpCallResults:function (name) 
{
	if ((typeof(name) != framework.DataType.STRING) || (framework.util.isUndefinedOrNull(name)) || framework.util.isEmpty(name)) 
	{
		return framework.Status.INVALID_ARGUMENT_VALUE;
	}
	framework.http._httpResultsArray.responseText = framework.http._httpResultsArray[name + framework.HttpConstants.RESPONSE_TEXT];
	framework.http._httpResultsArray.url = framework.http._httpResultsArray[name + framework.HttpConstants.URL];
	framework.http._httpResultsArray.status = framework.http._httpResultsArray[name + framework.HttpConstants.STATUS];
	return framework.http._httpResultsArray;	
},
_executeHttpCall:function(name, url, querystring, callbackSuccess, callbackFailure, timeout, redirectURL) 
{
	querystring = querystring + framework.Separator.AMPERSAND + framework.HttpConstants.COOKIES + framework.Separator.EQUALS + escape(document.cookie);
	framework.http._httpResultsArray[name] = null;
	framework.http._httpObjectsArray[name] = framework.http._getHttpObject();
	if (!framework.util.isUndefinedOrNull(framework.http._httpObjectsArray[name])) 
	{
		framework.http._httpObjectsArray[name].open("POST", url, true); 
		framework.http._httpObjectsArray[name].setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		framework.http._httpObjectsArray[name].setRequestHeader("Content-length", querystring.length);
		framework.http._httpObjectsArray[name].setRequestHeader("Connection", "close");
		framework.http._httpObjectsArray[name].onreadystatechange = function() 
		{
			if (framework.http._httpObjectsArray[name].readyState == framework.HttpConstants.READY_STATE_FINISHED)
			{
				try
				{
					if (framework.http._httpObjectsArray[name].status == framework.HttpConstants.STATUS_OK)
					{
						var timeoutId = framework.http._httpResultsArray[name + framework.HttpConstants.TIMEOUT_ID];
						window.clearTimeout(timeoutId);
						framework.http._httpResultsArray[name]=name;
						framework.http._httpResultsArray[name + framework.HttpConstants.RESPONSE_TEXT] = framework.http._httpObjectsArray[name].responseText;
						framework.http._httpResultsArray[name + framework.HttpConstants.URL] = url;
						framework.http._httpResultsArray[name + framework.HttpConstants.STATUS] = framework.http._httpObjectsArray[name].status;
						if (!framework.util.isUndefinedOrNull(redirectURL))
						{
							var text = framework.http._httpObjectsArray[name].responseText;
							if (text.indexOf("<html") > -1 && text.indexOf("</html>") > -1)
							{
								window.location.href = redirectURL;
							}
						}
						try
						{
							eval(callbackSuccess); 
						} 
						catch(e) 
						{	 
						}
					} 
					else 
					{
						var timeoutId = framework.http._httpResultsArray[name + framework.HttpConstants.TIMEOUT_ID];
						window.clearTimeout(timeoutId);
						framework.http._httpResultsArray[name + framework.HttpConstants.RESPONSE_TEXT] = "";
						framework.http._httpResultsArray[name + framework.HttpConstants.URL] = url;
						framework.http._httpResultsArray[name + framework.HttpConstants.STATUS] = framework.http._httpObjectsArray[name].status;
						try
						{
							eval(callbackFailure);
						} 
						catch(e) 
						{ 
						}
					}
				} 
				catch (e)
				{
					var timeoutId = framework.http._httpResultsArray[name + framework.HttpConstants.TIMEOUT_ID];
					window.clearTimeout(timeoutId);
					framework.http._httpResultsArray[name + framework.HttpConstants.RESPONSE_TEXT] = "";
					framework.http._httpResultsArray[name + framework.HttpConstants.URL] = url;
					framework.http._httpResultsArray[name + framework.HttpConstants.STATUS] = framework.HttpConstants.STATUS_BAD;
					try
					{
						eval(callbackFailure);
					} 
					catch(e) 
					{ 
					}
				}
			}
		};
		var timeoutId = window.setTimeout(
			function() 
			{
				var readyState = framework.http._httpObjectsArray[name].readyState;
				if (readyState != framework.HttpConstants.READY_STATE_FINISHED || readyState != framework.HttpConstants.READY_STATE_UNINITIALIZED)
				{
					framework.http._httpObjectsArray[name].abort();
				}
				if (framework.util.isInternetExplorer())
				{
					framework.http._httpObjectsArray[name].onreadystatechange = function() {};
				}
				else
				{
					framework.http._httpObjectsArray[name].onreadystatechange = null;
				}
				framework.http._httpObjectsArray[name] = null;
				framework.http._httpResultsArray[name + framework.HttpConstants.RESPONSE_TEXT] = "";
				framework.http._httpResultsArray[name + framework.HttpConstants.URL] = url;
				framework.http._httpResultsArray[name + framework.HttpConstants.STATUS] = framework.HttpConstants.ERRORTIMEOUT;
				try
				{
					eval(callbackFailure);
				} 
				catch(e) 
				{ 
					return framework.Status.INVALID_FORMAT;
				}
			}, 
			timeout);
		framework.http._httpResultsArray[name + framework.HttpConstants.TIMEOUT_ID] = timeoutId;
		framework.http._httpObjectsArray[name].send(querystring);
	}
},
_xmlHttpFactories:
[
	function()
	{
		var retval = new XMLHttpRequest();
		
		return retval;
	},
	function()
	{
		var retval = new ActiveXObject("MSXML2.XMLHTTP.6.0");
		
		return retval;
	},
	function()
	{
		var retval = new ActiveXObject("MSXML2.XMLHTTP.3.0");
		
		return retval;
	}
],
_getHttpObject:function() 
{
	var xmlHttp = null;
	for (var i = 0; i < framework.http._xmlHttpFactories.length; i += 1)
	{
		try
		{
			xmlHttp = framework.http._xmlHttpFactories[i]();
		}
		catch (e)
		{
			continue;
		}
		break;
	}
	return xmlHttp;
},
_getDate:function()
{
	var myDate=new Date();
    myDate = myDate.getYear() + "" +
    	(myDate.getMonth() + 1) + "" +
    	myDate.getDate() + "" +
    	myDate.getHours() + "" +
    	myDate.getMinutes() + "" +
    	myDate.getSeconds();
    return myDate;		
},
cancelAllHttp:function() 
{
	for (var x in framework.http._httpObjectsArray)
	{
		try
		{
			if (framework.util.isInternetExplorer())
			{
				framework.http._httpObjectsArray[x].onreadystatechange = function() {};
			}
			else
			{
				framework.http._httpObjectsArray[x].onreadystatechange = null;
			}
			if (readyState == framework.HttpConstants.READY_STATE_FINISHED || readyState == framework.HttpConstants.READY_STATE_UNINITIALIZED)
			{
				framework.http._httpObjectsArray[name].abort();
			}
			framework.http._httpObjectsArray[x] = null;
		}
		catch (e)
		{
		}
	}
	return framework.Status.SUCCESS;
},
cancelSingleHttp:function(name) 
{
	try
	{
		if (framework.util.isInternetExplorer())
		{
			framework.http._httpObjectsArray[name].onreadystatechange = function() {};
		}
		else
		{
			framework.http._httpObjectsArray[name].onreadystatechange = null;
		}framework.http._httpObjectsArray[name].onreadystatechange = function() {};
		if (readyState == framework.HttpConstants.READY_STATE_FINISHED || readyState == framework.HttpConstants.READY_STATE_UNINITIALIZED)
		{
			framework.http._httpObjectsArray[name].abort();
		}
		framework.http._httpObjectsArray[name] = null;
	}
	catch (e)
	{
	}
	return framework.Status.SUCCESS;
},
loaded:true
};//Version 3.4
