//
// XML HTTP Requests
//
// Based on the examples at www.w3school.org
//

var xmlhttp = null;
var onXMLComplete = null;

function createXmlHttp()
{
    xmlhttp = null;
    if (window.XMLHttpRequest)
    {   // code for all new browsers
        // disable IE for now
        if (navigator.appName == "Microsoft Internet Explorer")
            return;
        xmlhttp = new XMLHttpRequest();
    }
/*    else if (window.ActiveXObject)
    {   // code for IE
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e2) {
                xmlhttp = null;
            }
        }
    }*/
/*    else
    {
        alert("Your browser does not support XMLHTTP.");
    }*/
    return xmlhttp;
}

function loadXMLDoc(url)
{
    var xmlhttp = createXmlHttp();
    if (xmlhttp != null)
    {
        xmlhttp.onreadystatechange = state_Change;
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
    }
}

function postForm(url, data)
{
    var xmlhttp = createXmlHttp();
    if (xmlhttp != null)
    {
        xmlhttp.onreadystatechange = state_Change;
        xmlhttp.open("POST", url, true);
        xmlhttp.setRequestHeader("Content-type",   "application/x-www-form-urlencoded");
        xmlhttp.setRequestHeader("Content-length", data.length);
        xmlhttp.setRequestHeader("Connection",     "close");
        xmlhttp.send(data);
    }
}

function state_Change()
{
    if (xmlhttp.readyState == 4)
    {// 4 = "loaded"
        if (xmlhttp.status == 200)
        {// 200 = OK
            if (onXMLComplete != null)
                onXMLComplete(xmlhttp.responseXML);
        }
        else
        {
            alert("Problem retrieving XML data");
        }
    }
}


