/**
 * Replaces the HTML element with the given ID with the reply from the
 * HTTP request to the given URL.
 */
function replace_via_ajax(element_id, url) {
    var xmlhttp;

    // Build AJAX request and send it
    if(window.XMLHttpRequest == undefined) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        xmlhttp =  new XMLHttpRequest();
    }

    xmlhttp.open('GET', url, true);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            var div = document.getElementById(element_id);
            if(div == null) {
                alert("Unable to find element " + element_id);
                return;
            }
            div.innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}

