//<![CDATA[

// Does this browser support try-catch?
var tc = false;
try {
    tc = true;
} catch(f) { }


var xmlHttpError = 'XML HTTP Request: OK';  // for trouble shooting

function getRequestObject() {
    var objRequest;
    if (window.ActiveXObject) {
        if (tc) {
            try {
                objRequest = new ActiveXObject('Msxml2.XMLHTTP');  // IE 6+
            }
            catch(e) {
                try {
                    objRequest = new ActiveXObject('Microsoft.XMLHTTP');  // IE 5.5
                }
                catch(f) { }
            }
        } else {
            objRequest = new ActiveXObject('Microsoft.XMLHTTP');  // ? IE 5.0 ?
        }
    } else if (window.XMLHttpRequest) {
        objRequest = new XMLHttpRequest();  // All other browsers, inc. IE 7 and DOM 3
    }
    return objRequest;
}

function include(pUrl,pElementId,pImageSrc) {
    if (arguments.length==3) {  // if an image source is sent
        if (pImageSrc) {
            document.getElementById(pElementId).innerHTML='<img src="'+pImageSrc+'">';  // load the image while waiting
        }
    }
    if (arguments.length>=3) {  // if a targetElement ID is sent
        if (pImageSrc) {
            document.getElementById(pElementId).innerHTML='<img src="'+pImageSrc+'">';  // load the image while waiting
        }
    }

    var objRequest = getRequestObject();  // create a new request object

    if (typeof(objRequest)=='object') {  // if we have an object, and
        if (objRequest.readyState>=0) {  // if the object supports the correct properties...proceed
            objRequest.onreadystatechange = function() { handleHttpResponse(objRequest, pElementId); };  // specifiy the function to handle the results
                                                                // the correct request object is passed for us.
            objRequest.open('GET', pUrl, true);
            objRequest.send(null);
        }else{
            xmlHttpError = 'XML HTTP Request Object Unavailable';
            return false;
        }
    }else{
        xmlHttpError = 'XML HTTP Request Object Not Supported';
        return false;
    }
}

function handleHttpResponse(pObjRequest, pElementId) {
    if (pObjRequest.readyState==4) {
        if (pObjRequest.status==200) {
            document.getElementById(pElementId).innerHTML=pObjRequest.responseText;  // load the results into the element
            pObjRequest=null;  // dispose of the now un-needed object.
        }
    }
}
//-->
//]]>
