//Função exibe Página
function exibePagina(pagServidor,idObjeto)
{
	xmlhttp = criaXMLHTTP();
	obj = document.getElementById(idObjeto);	

	obj.style.display = 'block';
	
	xmlhttp.open('POST',pagServidor,true);
	xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			obj.innerHTML = xmlhttp.responseText;	
		}
	}
	
	xmlhttp.send(null);
}//FIM função exibe Página

function fechaObjeto(obj)
{	
	obj = document.getElementById(obj);
	obj.style.display = 'none';
}

//Função que exibe as notícias em destaque
function exibeDestaque(pagServidor,idObjeto,num,acao,clicado)
{
	xmlhttp = criaXMLHTTP();
	obj = document.getElementById(idObjeto);
	
	if(acao == 'pausar')
	{
		pausar();	
	}
	
	//coloca todos da mesma cor
	if(clicado)
	{
		for(i = 0; i < clicado; i++)
		{
			document.getElementById("linkDest"+i).style.backgroundColor = "#f0f0f0";
		}
		
		document.getElementById("linkDest"+num).style.backgroundColor = "#d0d0d0";
	}//FIM coloca todos da mesma cor
	
	if(document.getElementById("numDestaque") != null)
	{
		//document.getElementById("numDestaque").innerHTML = "<a href='javascript://' onclick=\"mudaNoticia("+num+",mudaNoticia.theArray);\">"+num+"</a>";
		document.getElementById("numDestaque").innerHTML = "<a href='javascript://' onclick=\"mudaNoticia("+num+",mudaNoticia.theArray);\"><img src='imagens/bt_continuar.png' alt='Continuar' border='0' /></a>";
	}

	obj.style.display = 'block';
	
	xmlhttp.open('POST',pagServidor,true);
	xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
		{
			obj.innerHTML = xmlhttp.responseText;	
		}
	}
	
	xmlhttp.send(null);
}//FIM Função que exibe as notícias em destaque


//função muda notícia destaque
function mudaNoticia(num,dest) 
{ 	
	//monta array
	mudaNoticia.theArray = new Array (dest.length); 
	for(i = 0; i < dest.length; i++)
	{
		mudaNoticia.theArray[i] = dest[i];
	}
	//fim monta array
		
		 if(num >= dest.length)
		 {
			num = 0;	 
		 }
			//se o elemento não existir ainda na capa
			if(document.getElementById("numDestaque") != null)
			{			
		  	 document.getElementById("linkDest"+(num)).style.backgroundColor = "#d0d0d0";			 
			 //muda cor de fundo
			 if(num == 0)
			 {document.getElementById("linkDest"+(dest.length-1)).style.backgroundColor = "#f0f0f0";}
			 else
			 {document.getElementById("linkDest"+(num-1)).style.backgroundColor = "#f0f0f0";}
			}//FIM se o elemento não existir ainda na capa
		
		exibeDestaque('includes/ler.php?id='+dest[num],'areaDestaque',num,'continuar');			
		tempo = window.setTimeout("mudaNoticia("+(num+1)+",mudaNoticia.theArray)",7000); 
	
} //FIM função muda notícia destaque

//Pausa notícia destaque
function pausar()
{
	clearTimeout(tempo);	
}//fim pausa notícia destaque


function janelaPadrao(url,nomeJan,margemTopo,margemEsquerda,largura,altura,barraRolagem)
{
 //window.open(url,nomeJan,'top='+margemTopo+',left='+margemEsquerda',width='+largura+', height='+altura+', scrollbars='+barraRolagem+'');
 
 window.open(url,nomeJan,"left="+margemEsquerda+", top="+margemTopo+", width="+largura+", height="+altura+", scrollbars="+barraRolagem+"");
}	






/*
	if(numero == 0)
	{
		exibePagina('includes/ler.php?id='+idNoticia+'','areaDestaque');
		window.setTimeout("mudaNoticia(1)",3000);
	}
	else if(numero == 1)
	{
		exibePagina('includes/ler.php?id='+idNoticia+'','areaDestaque');
		window.setTimeout("mudaNoticia(2)",3000);
	}
	else if(numero == 2)
	{
		exibePagina('includes/ler.php?id='+idNoticia+'','areaDestaque');
		window.setTimeout("mudaNoticia(3)",3000);
	}
	else if(numero == 3)
	{
		exibePagina('includes/ler.php?id='+idNoticia+'','areaDestaque');
		window.setTimeout("mudaNoticia(4)",3000);
	}
	else if(numero == 4)
	{
		exibePagina('includes/ler.php?id='+idNoticia+'','areaDestaque');
		window.setTimeout("mudaNoticia(0)",3000);
	}
*/
