dojo.addOnLoad(loadSlider);

var orologio = null;

function AggiornaContoAR() {

    if (!document.getElementById("infobar"))
        return;

    adesso = new Date();
    var timeLeft = Math.round(((fine - adesso.getTime()) / 1000) / 60);
    if (timeLeft > 0) {
        if (timeLeft < 6) {
            headlines[0] = sessionFewTimeLeftString.replace("{0}", timeLeft);
        } else {
            headlines[0] = sessionTimeLeftString.replace("{0}", timeLeft);
        }
        orologio = setTimeout("AggiornaContoAR()", 10000);
    } else {
        headlines[0] = sessionTimeOutString;
    }
}

function Ferma() {
    clearTimeout(orologio);
}

var cur = -1,dly = 5000,tID;
var transType = -1;
var headlines = new Array();
headlines[0] = undefined;
var isReading = false;

function loadSlider()
{
    jslog.debug('document.getElementById("infobar")=' + document.getElementById("infobar"));
    if (!document.getElementById("infobar"))
        return;

    dly = 100;
    clearTimeout(tID);
    if (! isReading)
        tID = setTimeout('change()', dly);
    dly = 7500;
    return;
}

function change()
{
    var infobar = document.getElementById("infobar");
    clearTimeout(tID);
    if (! isReading)
    {
        cur = (cur + 1) % headlines.length;
        while (headlines[cur] == undefined) {
            cur = (cur + 1) % headlines.length;
        }
	    document.getElementById("infobar").innerHTML = headlines[cur];
	    tID = setTimeout('change()', dly);
    }
}

