/**
 * fragment_url will be fetched asynchronously and given to the
 * innerHTML of the document element whose ID is element_id.
 *
 * This should work on Mozilla 1.x+ browsers, IE 5.x, IE 6.x, and Safari.
 */
function replaceElementWithFragment(element_id, fragment_url) {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        try { 
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
    }
    if (!xmlhttp){
        alert("XMLHttpRequest isn't supported by your browser. Sorry.");
        return false;
    }
    var element = document.getElementById(element_id);
    if (element == undefined) {
        alert("No element found with id " + element_id);
        return;
    }
    xmlhttp.open("GET", fragment_url);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
                element.innerHTML = xmlhttp.responseText;
            } else {
                element.innerHTML = '<p><b style="color:#400">' + xmlhttp.status + ':' + xmlhttp.statusText + '</b></p>';
            }
        }
    }
    
    xmlhttp.send(null);
}
