var http_request = false;

// The url is the URL on the server which will be called for content.
// The blockId is the span or div which will display the results of the call.
function makeRequest( url, callback ) {

    function ajaxBindCallback(){
        if (ajaxRequest.readyState == 4) {
            if (ajaxRequest.status == 200) {
                if (ajaxCallback){
                    ajaxCallback( ajaxRequest.responseText );
                } else {
                    // alert('no callback defined');
                }
            } else {
                // alert("There was a problem retrieving the data:\n" + ajaxRequest.status + ":\t" + ajaxRequest.statusText + "\n" + ajaxRequest.responseText);
            }
        }
    }

    // use a local variable to hold our request and callback until the inner function is called...
    var ajaxRequest = null;
    var ajaxCallback = callback;


    // bind our callback then hit the server...
    if (window.XMLHttpRequest) {
        // moz et al
        ajaxRequest = new XMLHttpRequest();
        ajaxRequest.onreadystatechange = ajaxBindCallback;
        ajaxRequest.open("GET", url, true);
        ajaxRequest.send(null);
    } else if (window.ActiveXObject) {
        // ie
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
        if (ajaxRequest) {
            ajaxRequest.onreadystatechange = ajaxBindCallback;
            ajaxRequest.open("GET", url, true);
            ajaxRequest.send();
        }
    }

}

function loadContent(url, id) {
    
  function callback() {
    var sep = (url.indexOf("?") >= 0) ? "&" : "?";
    url = url + sep + "rnd=" + Math.random();;
    makeRequest(url, function(response) {
        document.getElementById(id).innerHTML = response;
    });
  }

    // set onload depending on event handler API supported by browser
    if (window.addEventListener) {
        window.addEventListener("load", callback, false);
    } else {
        window.attachEvent("onload", callback);
    }
}


