var xmlhttp;
var element;
var ajaxResponseText;

function loadXMLDoc(url, elem, method, content) {
    element = elem;
    xmlhttp=null;
    ajaxResponseText = "";

    //false = wait for script to process before continuing
    //true = continue with processing rest of script while waiting for response
    if (method != "GET" && method != "POST")
        method = "GET";

    // code for Mozilla, etc.
    if (window.XMLHttpRequest) {
        xmlhttp=new XMLHttpRequest()
    }
    // code for IE
    else if (window.ActiveXObject) {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    }

    if (xmlhttp!=null) {
        xmlhttp.open(method,url,false);

        if (content) {
            xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
        }

        xmlhttp.onreadystatechange=state_Change;
        xmlhttp.send(content);
    }
    else {
        alert("Your browser does not support XMLHTTP.")
    }
}

function state_Change()
{
    // if xmlhttp shows "loaded"
    if (xmlhttp.readyState==4) {
        // if "OK"
        if (xmlhttp.status==200 || xmlhttp.status == 0) {
            //alert(xmlhttp.responseText);
            ajaxResponseText = xmlhttp.responseText;
            if (element) {
                document.getElementById(element).innerHTML=xmlhttp.responseText;
            }
        }
        else {
            alert("Problem retrieving data:" + xmlhttp.statusText)
        }
    }
}
