function iniciarPropaganda() {
	mostrarPropaganda();
	setTimeout('esconderPropaganda()', 8000);
}

function mostrarPropaganda() {
	propaganda = document.getElementById('camadaPropaganda');
	setVisible('camadaPropaganda', true);
}

function esconderPropaganda() {
	setVisible('camadaPropaganda', false);
}

function setVisible(itemToChange, visible){
	objItemToChange = document.getElementById(itemToChange);
	if (visible) {
		objItemToChange.style.display='';
	} else {
		objItemToChange.style.display='none';
	}
}

function deolho() {
	NewWindow('deolho.php', 'deOlho', 400, 300, 'no');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage,myname,settings)
}

function abrirPopup(video, w, h) {
	aposleft = screen.width/2 - w/2;
	apostop = screen.height/2 - h/2;
	var desktop = window.open(video, '_blank', 'width='+w+',height='+h+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,left='+aposleft+',top='+apostop)
}

function imagemDaSemana (img) {
	_imagem = document.getElementById('imagemAtualDaSemana');
	_texto = document.getElementById('textoAtualDaSemana');
	_imagem.src = img.src;
	_imagem.title = img.title;
	_imagem.alt = img.alt;
	_texto.innerHTML = img.title;
}
function saudacao() {
	day = new Date( );
	hr = day.getHours( );
	if (( hr >= 0 ) && (hr <= 4 ))
		mess1= "Boa-madrugada!";
	else if (( hr >= 4 ) && (hr < 12))
		mess1= "Bom-dia!";
	else if (( hr >= 12) && (hr <= 17))
		mess1= "Boa-tarde!";
	else if ((hr >= 18) && (hr <= 23))
		mess1= "Boa-noite!";
	document.write(mess1)	
}

function cssHoverOverFix(elemento) {
	if (elemento.className.indexOf('_hover') == -1)
		elemento.className = elemento.className + '_hover';
}
function cssHoverOutFix(elemento) {
	index = elemento.className.indexOf('_hover');
	if (index != -1)
		elemento.className = elemento.className.substr(0, index);
}
/* Fade noticias */
atual = 1;
timeoutId = 0;
fade = false;
total = 5;
divBlend = 'imagemNoticiaPrincipal';
_botaoAnterior = null;
tempo = 12000;

function changeOpac(opacity){
	var crossobj = document.getElementById(divBlend);
	if (crossobj.filters)
		crossobj.filters.alpha.opacity=opacity;
	crossobj.style.opacity=(opacity/101);
} 

function blend(){
	var crossobj = document.getElementById(divBlend);
	var speed=30;
	var timer=0;
	if (crossobj.filters) crossobj.className = 'imagemNoticiaPrincipal';
	for(i=100;i>0;i-=10) setTimeout('changeOpac('+i+')', timer++ * speed);
	setTimeout('preencher()', timer * speed);
	for(i=0;i<=100;i+=10) setTimeout('changeOpac('+i+')', timer++ * speed);
	if (crossobj.filters) setTimeout("document.getElementById(divBlend).className = 'imagemNoticiaPrincipal2';", timer * speed);
	
}

function frente() {
	posicao = atual + 1;
	if (posicao > total)
		irPara(1);
	else
		irPara(posicao);
}

function tras() {
	posicao = atual - 1;
	if (posicao == 0)
		irPara(total);
	else
		irPara(posicao);
}

function irPara(posicao) {
	atual = posicao;
	clearAndBlend();
	timeoutId=setTimeout('iniciar()', tempo);
}

function pararTimerNoticias() {
	clearTimeout(timeoutId);
}

function clearAndBlend() {
	pararTimerNoticias();
	blend();
}

function iniciar(){
	if (fade) {
		frente();
	} else {
		fade = true;
		timeoutId=setTimeout('iniciar()', tempo);
	}
}
function preencher() {
	_imagem = document.getElementById('imagemNoticiaPrincipal');
	_titulo = document.getElementById('tituloNoticiaPrincipal');
	_fonte = document.getElementById('fonteNoticiaPrincipal');
	
	_botaoAtual = document.getElementById('botaoPrincipal' + atual);
	if (_botaoAnterior == null)
		_botaoAnterior = document.getElementById('botaoPrincipal1');
	_botaoAnterior.className = 'botaoPrincipal';
	_botaoAtual.className = 'botaoPrincipal botaoPrincipalAtivo';
	_botaoAnterior = _botaoAtual;
	
	_imagem.innerHTML = arrayImagens[atual - 1];
	_titulo.innerHTML = arrayTitulos[atual - 1];
	_fonte.innerHTML = arrayFontes[atual - 1];
	
/*	_imagem.innerHTML = '<img src="imagens/fotoTest.jpg" width="298" height="232" />';
	_titulo.innerHTML = 'bleh';
	_fonte.innerHTML = 'blih'; */
}