var AJAXxmlHttpObj = false;
var AJAXxmlHttpObjBusy = false;
var AJAXElementToUpdate = null;

function AJAXcreateObject()
{
    try
    {
        AJAXxmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
        try
        {
            AJAXxmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E)
        {
            AJAXxmlHttpObj = false;
        }
    }

    if (!AJAXxmlHttpObj && typeof XMLHttpRequest!='undefined')
    {
        AJAXxmlHttpObj = new XMLHttpRequest();
    }
}

function AJAXprocessResponseEval()
{
    if (!AJAXxmlHttpObj)
		 return;

    if (AJAXxmlHttpObj.readyState == 4)
    {
        AJAXxmlHttpObjBusy = false;
        if (AJAXxmlHttpObj.responseText != "")
        {
            try
            {
                eval(AJAXxmlHttpObj.responseText);
            }
            catch(E)
            {
                // do nothing
            }
        }
    }
}

function AJAXmakeRequest(request_url)
{
    if (AJAXxmlHttpObjBusy || !AJAXxmlHttpObj)
        return;

    AJAXxmlHttpObjBusy = true;
    AJAXxmlHttpObj.open("GET", request_url);
    AJAXxmlHttpObj.onreadystatechange = AJAXprocessResponseEval;
    AJAXxmlHttpObj.send(null);
}

function AJAXprocessResponseWithUpdate()
{
    if (!AJAXxmlHttpObj)
         return;

    if (AJAXxmlHttpObj.readyState == 4)
    {
        AJAXxmlHttpObjBusy = false;
        if (AJAXxmlHttpObj.responseText != "" && AJAXElementToUpdate)
            AJAXElementToUpdate.innerHTML = AJAXxmlHttpObj.responseText;
        else
            AJAXElementToUpdate.innerHTML = "error";
    }
}

function AJAXmakeRequestAndUpdate(request_url, element_id)
{
    AJAXElementToUpdate = null;
    if (AJAXxmlHttpObjBusy || !AJAXxmlHttpObj)
        return;

    AJAXElementToUpdate = document.getElementById(element_id);

    AJAXxmlHttpObjBusy = true;
    AJAXxmlHttpObj.open("GET", request_url);
    AJAXxmlHttpObj.onreadystatechange = AJAXprocessResponseWithUpdate;
    AJAXxmlHttpObj.send(null);
}

function AJAXinit()
{
    AJAXcreateObject();
    AJAXxmlHttpObjBusy = false;
}

AJAXinit();
