var oHTTPRequest = null;

function CreateHTTPRequest()
{
if (window.XMLHttpRequest) /* Mozilla, Safari,...  */
{
	oHTTPRequest = new XMLHttpRequest();

if (oHTTPRequest.overrideMimeType)
oHTTPRequest.overrideMimeType("text/xml");
}
else if (window.ActiveXObject) /* IE */
{
try { oHTTPRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { }
try { oHTTPRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
}
if (oHTTPRequest == null)
{
alert("Cannot create XMLHTTP instance");
return null;
}
else
return oHTTPRequest;
}

/**************************************

    bPostMethod : true = POST, false = GET (bool)

    sUrl : Url with Parameters (string)

    sCallbackFunction : Callback Function Name (string)

    bGetValue : Get Result Object = true, or not = false

    bXml : Returns Object is XML = true, or Text = false (bool)

    oReturnParams : Set parameter to Callback function (object)

**************************************/

function MakeAjaxRequest(bPostMethod, sUrl, sCallbackFunction, bGetValue, bXml, oReturnParams)
{
oHTTPRequest = CreateHTTPRequest();
oHTTPRequest.onreadystatechange = function()
{
if (oHTTPRequest.readyState == 4)
{
if (sCallbackFunction == "")
{
if (oHTTPRequest.status != 200)
alert("There was a problem with the request.(Code: " + oHTTPRequest.status + ")");
}
else
{
if (oHTTPRequest.status == 200)
{
var sRetVal = CheckReturnParams(oReturnParams);
sRetVal = sRetVal != "" ? ",'" + sRetVal + "'" : "";
if (bGetValue)
{
if (bXml)
eval(sCallbackFunction + "(oHTTPRequest.responseXML" + sRetVal + ");");
else
eval(sCallbackFunction + "(oHTTPRequest.responseText" + sRetVal + ");");
}
else
eval(sCallbackFunction + "('" + sRetVal + "');");
}
else
alert("There was a problem with the request.(Code: " + oHTTPRequest.status + ")");
}
}
}
if (bPostMethod)
oHTTPRequest.open("POST", sUrl, true);
else
oHTTPRequest.open("GET", sUrl, true);
oHTTPRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
oHTTPRequest.send(null);
}

function CheckReturnParams(oReturnParams)
{
if (oReturnParams == "")
return "";
else
{
var oAry = oReturnParams.split(",");
return oAry;
}
}
/*  MakeAjax Functions.. */
function MakeAjaxRequestG(sUrl)
{
MakeAjaxRequest(false, sUrl, "", false, false, "");
}
function MakeAjaxRequestGC(sUrl, sCallbackFunction)
{
MakeAjaxRequest(false, sUrl, sCallbackFunction, false, false, "");
}

function MakeAjaxRequestGCG(sUrl, sCallbackFunction)
{
MakeAjaxRequest(false, sUrl, sCallbackFunction, true, false, "");
}
function MakeAjaxRequestGCGR(sUrl, sCallbackFunction, oReturnParams)
{
MakeAjaxRequest(false, sUrl, sCallbackFunction, true, false, oReturnParams);
}
function MakeAjaxRequestGCGX(sUrl, sCallbackFunction, oReturnParams)
{
MakeAjaxRequest(false, sUrl, sCallbackFunction, true, true, oReturnParams);
}