// JavaScript Document

var timerMeuMenu;
var destVisivel;
var arrLinkDestaques;
var timeToDest = 3000;
var resTimer;
var textH2;



function timerDest()
{
	if(timeToDest != 0) resTimer = setTimeout("nextDest(); timerDest();", timeToDest);
}

function mudaDestTopo(e)
{
	if(typeof(e)=='undefined')var e=window.event;
    source=e.target?e.target:e.srcElement;
    //Correção para o bug do Konqueror/Safari
    if(source.nodeType==3)source=source.parentNode;
	
	if(resTimer) clearTimeout(resTimer);
	timeToDest = 0;
	showDest(source.firstChild.nodeValue);
}

function prevDest(e)
{
	nextVisivel = "0"+(destVisivel-1);
	if(nextVisivel == "00") nextVisivel = "05";
	showDest(nextVisivel); 
	if(e) return poin(e);	
}

function nextDest(e)
{
	nextVisivel = "0"+(parseInt(destVisivel)+1);
	if(nextVisivel == "06") nextVisivel = "01";
	showDest(nextVisivel); 
	if(e) return poin(e);	
}

function showDest(id)
{
	
	for(i=0; i<arrLinkDestaques.length; i++)
	{
		if(arrLinkDestaques[i].parentNode.className != "setas")
		{
			if(i+1 == 0+id)
				arrLinkDestaques[i].parentNode.className = "show";
			else
				arrLinkDestaques[i].parentNode.className = "";
		}
	}
	
	
	if(gE('d_'+destVisivel)) gE('d_'+destVisivel).className = "";
	if(gE('d_'+id))
	{
		destVisivel = id;
		gE('d_'+id).className = "show";
		/*
		h2Topo = gE('destaques').getElementsByTagName('h2')[0];
		while(h2Topo.hasChildNodes()) h2Topo.removeChild(h2Topo.firstChild);
		
		if(textH2[id] == "")
			textH2[id] = gE('d_'+id).getElementsByTagName('h2')[0].firstChild.cloneNode();
		
		h2Topo.appendChild(textH2[id]);*/
	}
}

function clock()
{
	dataNow = new Date;
	
	spanClock = gE('noticias').getElementsByTagName('h2')[0].getElementsByTagName('span')[0].firstChild;
	if(dataNow.getHours()<10) hora = "0"+dataNow.getHours();
	else hora = dataNow.getHours();
	
	if(dataNow.getMinutes()<10) minutos = "0"+dataNow.getMinutes();
	else minutos = dataNow.getMinutes();
	
	if(dataNow.getSeconds()<10) segundos = "0"+dataNow.getSeconds();
	else segundos = dataNow.getSeconds();
	
	spanClock.nodeValue = hora+":"+minutos+":"+segundos;
	setTimeout('clock();',1000);
}

function exibeDestaquesPorOpcao(e)
{
	postString = "strUrl="+getSrc(e).href.replace("http://"+document.domain,"");
	XHR_Opcoes.open('post', '/ajax.php?r=9&rand='+Math.floor(Math.random()*100), true);
	XHR_Opcoes.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	XHR_Opcoes.onreadystatechange=responseOpcoes;
	XHR_Opcoes.send(postString);
	return poin(e);
}


