
var xslDocLoaded = false;
var xmlHttp = false;

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
    // conditional compilation so 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') 
{
    try 
    {
        xmlHttp = new XMLHttpRequest()
    } 
    catch (e) 
    {
        xmlHttp = false
    }
}
if (!xmlHttp && window.createRequest) 
{
    try 
    {
        xmlHttp = window.createRequest()
    } 
    catch (e) 
    {
        xmlHttp = false
    }
}

function postToServer(strUrl, strSend, divOutput, bShowError, bAsync, funcCallback)
{     

    if(!xmlHttp)
    {
        if (bShowError)
        {
            alert('Sorry. Cannot process. You\'re browser does not support xml posting technology.')    
        }
    }
    else
    {
        if(!strSend)
            strSend = ''
        
        if (divOutput)
            divOutput.innerHTML = '<img src="Images/Loading.gif" alt="Loading" title="Loading" />'
       
        xmlHttp.abort()
        
        onreadystatechangeTemp=function() 
        {
            if (xmlHttp.readyState==4) 
            {
                if(xmlHttp.status == 200)
                {
                    if(divOutput)
                        divOutput.innerHTML = xmlHttp.responseText
                    else if(funcCallback)
                        funcCallback(xmlHttp.responseText)
                }
                else
                {
                    if(divOutput)
                        divOutput.innerHTML = '<span class="highlight">An error occured. It is most likely to be a temporary problem. Sorry for any inconvenience. Try again soon.</span>'
                    else if(funcCallback)
                        funcCallback(xmlHttp.responseText)
                }
            }
        }
        if(bAsync)
        {
            xmlHttp.onreadystatechange = onreadystatechangeTemp
        }
        
        xmlHttp.open("POST",strUrl, bAsync);
        xmlHttp.setRequestHeader("Content-Type", "application/xml")
        xmlHttp.setRequestHeader('User-Agent', "Time Dial http://www.timedial.net")

        xmlHttp.send(strSend)
        
        if(!bAsync)
        {
            onreadystatechangeTemp()
        }
    }
    
    return xmlHttp != null
}
