/**
 * XHR Functions
 */

/**
 * Create a XHR object cross-browser
 *
 * @return XHR object
 */
function obj_ajax() {
    var xmlhttp = false;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
        xmlhttp = new XMLHttpRequest();
    return xmlhttp;
}

/**
 * Fetch contents from external url
 *
 * @param url
 * @return Server content response
 */
function fetch_contents(url) {
    var requestObj = obj_ajax();
    requestObj.open("GET", url, false);
    requestObj.send(null);
    return requestObj.responseText;
}

/**
 * Callback server and return the server response
 *
 * @param url
 * @return Server content response
 */
function call_server(url) {
    return fetch_contents(url);
}

