var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

function InitializeTimer()
{
    secs = 6;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock();
        var titulodestaque = document.getElementById("divTitulo");
        var imagemdestaque = document.getElementById("divImg");
        var apresedestaque = document.getElementById("divApresentacao");
        titulodestaque.innerHTML = "<a href='produtos_unico.asp?c=" + codigo[atual] + "' class='titPrd'>" + titulo[atual] + "</a>";
        imagemdestaque.innerHTML = "<a href='produtos_unico.asp?c=" + codigo[atual] + "'><img src='" + images[atual] + "' width='390' height='240' border='0'></a>";
        apresedestaque.innerHTML = "<a href='produtos_unico.asp?c=" + codigo[atual] + "'>" + apresentacao[atual] + "</a>";

        atual ++;
        if (parseInt(atual) >= parseInt(codigo.length)) {atual = 0;}
        
		InitializeTimer();
    }
    else
    {
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}
