<!-- this is a generic function to call an external web page and return its contents -->
function getHTTPObject() {
    var xhr = false;//set to false, so if it fails, do nothing -->
    if(window.XMLHttpRequest) {//detect to see if browser allows this method
        var xhr = new XMLHttpRequest();//set var the new request
    } else if(window.ActiveXObject) {//detect to see if browser allows this method
        try {
            var xhr = new ActiveXObject("Msxml2.XMLHTTP");//try this method first
        } catch(e) {//if it fails move onto the next
        try {
            var xhr = new ActiveXObject("Microsoft.XMLHTTP");//try this method next
        } catch(e) {//if that also fails return false.
            xhr = false;
        }
    }
    }
    return xhr;//return the value of xhr
}

<!-- call-back function - used to load results of getHTTPObject call into this page, into the textSection div layer -->
function displayResponse(request,sectionId) {
    if(request.readyState == 4){//waits for the complete before execute.
        if(request.status != 304){ 
            var results = document.getElementById(sectionId);
            results.innerHTML = request.responseText;        
        }
    }
    onContentLoad();
}
<!-- called by clicking on the posting links; calls getHTTPObject with displayResponse as the callback function 
<!--     parameters :  -->
<!--        resourceURI - URI of the page we are loading -->
<!--        section - DOM element ID we should load the text into -->

function loadContentIntoSection(resourceURI,section) {
    var request = getHTTPObject();
    if(request){
        request.onreadystatechange = function() {
            displayResponse(request,section);
        }; <!-- calls 'displayResponse' when the request to the external page is returned -->
    }
    var base = "/include";
    var url = base + "/" + resourceURI + ".xml"; <!-- build the URL of the page to retrieve -->
    request.open("GET", url, true);  <!-- open the URL -->
    request.send(null); <!-- complete the request -->
}

function getDomain () {
//simple function that matches the beginning of a URL
//in a string and then returns the domain.
var urlpattern = new RegExp("(http|ftp|https)://(.*?)/.*$");
var location = document.location.href;
var parsedurl = location.match(urlpattern);
return parsedurl[2];
}
