/*
 * Perform a synchronous ajax request by invoking the supplied url and returning
 * the request response text.
 */
function synchronousAjaxRequest(url) {

    ajaxRequest = false;
    
    if (window.XMLHttpRequest) {
        ajaxRequest = new XMLHttpRequest();

    } else if (window.ActiveXObject) {
        try {            
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {            
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                ajaxRequest = false;
            } 
        }
    } else {
        ajaxRequest = false;
    }
    if (ajaxRequest) {
        ajaxRequest.open("Get",url+preventCachingUrlParameter(url),false);
        ajaxRequest.send("");
        return ajaxRequest.responseText;
    }
    return null;
}

/*
 * Perform an asynchronous ajax request by invoking the supplied url and returning
 * the request response text to the supplied call-back function.
 */
function asynchronousAjaxRequest(url,callBack) {

    ajaxRequest = false;
    
    if (window.XMLHttpRequest) {
        ajaxRequest = new XMLHttpRequest();

    } else if (window.ActiveXObject) {
        try {            
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {            
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                ajaxRequest = false;
            } 
        }
    } else {
        ajaxRequest = false;
    }        
    if (ajaxRequest) {
        ajaxRequest.onreadystatechange=function() {
            if (ajaxRequest.readyState==4) {
                callBack(ajaxRequest.responseText);
            }
        }
        ajaxRequest.open("Get",url+preventCachingUrlParameter(url),true);
        ajaxRequest.send(null);
    }
}
 
/*
 * Generates a request parameter suitable to make the supplied url unique. This can be used
 * to prevent the url from being cached by the browser.
 */
function preventCachingUrlParameter(url) {
    return (url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime();
}
