var xmlhttp = false;

function XMLHttpSend(url, callbackfunction, method)
{
        xmlhttp = false;
        /*@cc_on @*/
        /*@if (@_jscript_version >= 5)
        // JScript gives us Conditional compilation, we can cope with old IE versions.
        // and security blocked creation of the objects.
        try
        {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
                try
                {
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e)
                {
                        xmlhttp = false;
                }
        }
        @end @*/
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
        {
                xmlhttp = new XMLHttpRequest();
        }

        xmlhttp.onreadystatechange = function()
        {
                if (xmlhttp.readyState == 4)
                {
                        eval(callbackfunction);
                }
        }
        if(url.indexOf("?") != -1)
        {
                url += '&randomnumber=' + Math.random();
        }
        else
        {
                url += '?randomnumber=' + Math.random();
        }
        
        if(method != 'GET' && method != 'POST')
        {
                method = 'GET';
        }
        
        xmlhttp.open(method, url, true);
        xmlhttp.send(null)
}

function XMLHttpCallBack()
{
        var res = xmlhttp.responseText;
        try
        {
                eval(res);
        }
        catch (e)
        {
                // do nothing
        }
}

// variation on XMLHttp_CallBack() but writes response (which is in HTML) to the specified HTML id (i.e. a div)
function HTML_XMLHttpCallback(id)
{
        var div = document.getElementById(id);
        var res = xmlhttp.responseText;
        if(div)
        {
                try
                {
                        div.innerHTML = res;
                }
                catch (e)
                {
                        // nothing
                }
        }
}