﻿// This is dedicated to the query the restfull webservice like, in order to update the
// counter on the top page.

getNumber();
setTimeout("updateCounterBasedOnValue()", 1000);

function updateCounterBasedOnValue() 
{
    getNumber();   
}

function getNumber_return(pageRequest) {

    if (pageRequest.readyState != 4)    return;
    if (pageRequest.status != 200)      return;

    loadticker(pageRequest.responseText);
    setTimeout("updateCounterBasedOnValue()", 5000);
}

function getNumber() {

    var url;
    var pageRequest = false;

    url = 'http://' + document.domain + '/includes/all/utils/totalcalls.asp';

    if (window.XMLHttpRequest){
        pageRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        pageRequest = new ActiveXObject('Msxml2.XMLHTTP');
        if (pageRequest == null) {
            pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    else{
        return false;
    }

    pageRequest.onreadystatechange = function() {
        getNumber_return(pageRequest);
    }

    pageRequest.open('POST', url, true);
    pageRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    pageRequest.send('data');    //Do not send null, otherwise it doesn't work with Firefox, as firefox doesn't accept undefined content-length. By sending something not null the content-length is set by Firefox
}
