var index = 1; var menu_time = 5000; var timer = setTimeout('painelTrocaMsg()',menu_time); function painelTrocaMsg() { index = index % maximo +1; painelChannel(index); painelTempo(); } function painelTempo() { clearTimeout(timer); timer = setTimeout("painelTrocaMsg()",menu_time); } function painelChannel(id) { index = id; if(document.getElementById("a_painel_" + id) && (document.getElementById("a_painel_" + anterior))){ document.getElementById("a_painel_" + anterior).className= ""; document.getElementById("a_painel_" + id).className = "ativo"; document.getElementById('paineldivs').innerHTML = document.getElementById('li_painel_' + id).innerHTML; } anterior = id; } function painelCh(id, out) { if (out == 1) { clearTimeout(timer); painelChannel(id); } else { painelTempo(); } }