function chamaTesteVideo(url,titulo,rel){
	Videobox.open(url,titulo,rel);	
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//var tamanho = "11px";
function aumentarLetra(i){
	tamanho = document.getElementById("tamanho_"+i).value;
	switch (tamanho) {
		case "17px":
			tamanho = "17px";
			break;
		case "15px":
			tamanho = "17px";
			break;
		case "13px":
			tamanho = "15px";
			break;
		case "11px":				
			tamanho = "13px";
			break
		case "9px":
			tamanho = "11px";
			break
	}
	elemento = document.getElementById("letra_"+i);
	document.getElementById("tamanho_"+i).value = tamanho;
	elemento.style.fontSize = tamanho;
}

// diminuir o tamanho da letra
function diminuirLetra(i){
	tamanho = document.getElementById("tamanho_"+i).value;
	switch (tamanho) {
		case "9px":
			tamanho = "9px";
			break
		case "11px":				
			tamanho = "9px";
			break
		case "13px":
			tamanho = "11px";
			break
		case "15px":
			tamanho = "13px";
			break
		case "17px":
			tamanho = "15px";
			break
	}
	elemento = document.getElementById("letra_"+i);
	document.getElementById("tamanho_"+i).value = tamanho;
	elemento.style.fontSize = tamanho;
}

function tiraEspaco(texto){
	while(texto.indexOf(" ") != -1){
	  texto = texto.replace(" ","");
	}
    return texto;
}

var secaoClique;
function ativaOpcaoMenu(secaoDiv){
	secaoClique = secaoDiv;
	desativaOpcaoMenu();
	document.getElementById(secaoDiv).style.backgroundPosition="left -48px";	
	document.getElementById(secaoDiv).style.cursor="default";
	document.getElementById(secaoDiv).disabled = true;	
	document.getElementById("content").style.background="url('img/bg-content-intern.jpg')";
	document.getElementById("content").style.padding="0px 0px 0px 0px";
}
var secoes = new Array("btPeRua","btEquipe","btProgramas","btVoceFaz","btBaixe","btContatoNav");
function desativaOpcaoMenu(){
	for(i=0; i < secoes.length; i++){
		document.getElementById(secoes[i]).style.backgroundPosition="left 0px";
		document.getElementById(secoes[i]).style.cursor="pointer";	
		document.getElementById(secoes[i]).disabled = false;		
	}
}
function ativaOverOpcaoMenu(secaoDiv){
	document.getElementById(secaoDiv).style.backgroundPosition="left -48px";	
}
function ativaOutOpcaoMenu(secaoDiv){
	if(secaoClique != secaoDiv){
		document.getElementById(secaoDiv).style.backgroundPosition="left 0px";	
	}
}
function setarValorHomeSecaoClique(){
	secaoClique = "Home";
}

function chamaNoticiasHome(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao('colLeft','ler_pagina_remota.php?pagina=1&noticiasHome=1',mensagem);
}

function chamaListaNoticiasHome(pagina){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao2('colRight','ler_pagina_remota.php?pagina=1&listaNoticias='+pagina,mensagem);
}

function chamaListagemTodasNoticias(pagina){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao2('colLeft','ler_pagina_remota.php?pagina='+pagina+'&listagem=1',mensagem);
}

function chamaNoticiaSelecionada(id,divSelecionado){
	//document.getElementById(divSelecionado).style.display = 'none';
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao2('colLeft','ler_pagina_remota.php?pagina=1&noticiasHome='+id,mensagem);
}

function chamaComentarioNoticia(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao2('divCarregaOpcaoMenuNoticia','ler_pagina_remota.php?pagina=1&noticiasComentario='+id,mensagem);
}

function chamaEnviarNoticiaAmigo(id){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao2('divCarregaOpcaoMenuNoticia','ler_pagina_remota.php?pagina=1&noticiasAmigo='+id,mensagem);
}

function carregaNoticiaAnteriorNaListagemAtual(noticiaId){
	mensagem = 'Carregando...';
	enviaRequisicao('colRight','ler_pagina_remota.php?pagina=1&noticiasListaAnterior='+noticiaId,mensagem);
}

function chamaHome(){
	voltarProgramas();
	setarValorHomeSecaoClique();
	desativaOpcaoMenu();
	document.getElementById("content").style.background="url('img/bg-content.jpg')";
	document.getElementById("content").innerHTML = "<div id='colLeft'><!-- Div ColLeft --></div><!-- Fim Div ColLeft --><hr /><div id='colRight'><!-- Div ColRight --></div><!-- Fim Div ColRight --><div class='clear'></div>";
	chamaNoticiasHome();
	chamaListaNoticiasHome('1');
}

function chamaPenaRua(){
	ativaOpcaoMenu("btPeRua");
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao('content','pe-na-rua.php',mensagem);
}
function chamaEquipe(){
	ativaOpcaoMenu("btEquipe");
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao('content','equipe.php',mensagem);
}
function chamaProgramas(){
	ativaOpcaoMenu("btProgramas");
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao('content','ler_pagina_remota.php?pagina=1&programaAnterior=1',mensagem);
}
function chamaVoceFaz(){
	ativaOpcaoMenu("btVoceFaz");
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao('content','voce-faz.php',mensagem);
}
function chamaBaixe(){
	ativaOpcaoMenu("btBaixe");
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao('content','baixe-trilha.php',mensagem);
}
function chamaContato(){
	ativaOpcaoMenu("btContatoNav");
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	enviaRequisicao('content','contato.php',mensagem);
}
function chamaPrograma(programa){
	location.href="#sobe";
	document.getElementById('slideShowIntern').style.display = 'block';
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:500px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Carregando...</div>'
	//url = "programas/programa"+programa+".htm";
	enviaRequisicao3('slideShowIntern','ler_pagina_remota.php?pagina=1&programa='+programa,mensagem);
	document.getElementById('slideShow').style.display = 'none';
}

function voltarProgramas(){
	document.getElementById('slideShow').style.display = 'block';
	document.getElementById('slideShowIntern').style.display = 'none';
}



function submitComentario(){

	if(tiraEspaco(document.getElementById('nome').value) == ""){	
		alert("Informe o nome");
		document.getElementById('nome').focus();
		return;
	}
	if(document.getElementById('email').value == ""){
		alert("Informe o email");
		document.getElementById('email').focus();
		return;	
	}else{	
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value))){ 
			alert("E-mail com formato correto");
			document.getElementById('email').focus(); 
	   	    return;
	    }
	} 	
	if(tiraEspaco(document.getElementById('comentario').value) == ""){
		alert("Informe o comentário");
		document.getElementById('comentario').focus();
		return;
	}
	setarCamposComentarios();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Enviando...</div>'
	enviarForm('ler_pagina_remota_post.php',campos,'divCarregaComentariosCadastrados',mensagem);
}

function setarCamposComentarios(){
	campos = "nome="+encodeURI(document.getElementById('nome').value);
	campos += "&email="+encodeURI(document.getElementById('email').value);
	campos +="&comentario="+encodeURI(document.getElementById('comentario').value);
	campos +="&noticia="+document.getElementById('noticia').value;
}

function submeterEnviaAmigo(){

	if(tiraEspaco(document.getElementById('nomeRemetente').value) == ""){
		alert("Informe o seu nome.");
		document.getElementById('nomeRemetente').focus();
		return false;
	}
	if(tiraEspaco(document.getElementById('emailRemetente').value) == ""){
		alert("Informe o e-mail");
		document.getElementById('emailRemetente').focus();
		return false;	
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailRemetente').value))){ 
			alert("E-mail inválido.");
			document.getElementById('emailRemetente').focus();
			return false;
	    } 
	}
	if(tiraEspaco(document.getElementById('nomeDestinatario').value) == ""){
		alert("Informe o nome do destinatário.");
		document.getElementById('nomeDestinatario').focus();
		return false;
	}
	if(tiraEspaco(document.getElementById('emailDestinatario').value) == ""){
		alert("Informe o e-mail do destinatário");
		document.getElementById('emailDestinatario').focus();
		return false;	
	}else{
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailDestinatario').value))){ 
			alert("E-mail destinatário inválido.");
			document.getElementById('emailDestinatario').focus();
			return false;
	    } 
	}
	divSelecionado = "divEnviarParaAmigo" + document.getElementById('noticia').value;
	setarCamposEnviarAmigo();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Enviando...</div>'
	enviarForm('ler_pagina_remota_post.php',campos,divSelecionado,mensagem);
}

function setarCamposEnviarAmigo(){
	campos = "nomeRemetente="+encodeURI(document.getElementById('nomeRemetente').value);
	campos += "&emailRemetente="+encodeURI(document.getElementById('emailRemetente').value);
	campos +="&nomeDestinatario="+encodeURI(document.getElementById('nomeDestinatario').value);
	campos +="&emailDestinatario="+document.getElementById('emailDestinatario').value;
	campos +="&noticiaId="+document.getElementById('noticia').value;
}

function chamaRetornoEnvioAmigo(divSelecionado){
	document.getElementById('noticia').innerHTML = "E-mail enviado com sucesso.";
}

function abrePageImpresao(valor){
	window.open ("http://www.insertblog.com.br/template/penarua/imprimir.php?id="+valor,"imprimir","menubar=no,resizable=no,scrollbars=yes,width=613,height=650"); 
	//window.open ("http://www.4dimensao.net/insertblog.com.br/template/penarua/imprimir.php?id="+valor,"imprimir","menubar=no,resizable=yes,scrollbars=yes,width=625,height=650"); 
}

function submeterVoceFaz(){

	if(tiraEspaco(document.getElementById('nomeVoceFaz').value) == ""){	
		alert("Informe o nome");
		document.getElementById('nomeVoceFaz').focus();
		return;
	}
	if(document.getElementById('emailVoceFaz').value == ""){
		alert("Informe o email");
		document.getElementById('emailVoceFaz').focus();
		return;	
	}else{	
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailVoceFaz').value))){ 
			alert("E-mail com formato correto");
			document.getElementById('emailVoceFaz').focus(); 
	   	    return;
	    }
	} 	
	if(tiraEspaco(document.getElementById('sugestaoVoceFaz').value) == ""){
		alert("Informe o comentário");
		document.getElementById('sugestaoVoceFaz').focus();
		return;
	}
	setarVoceFaz();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:100px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Enviando...</div>'
	enviarForm('ler_pagina_remota_post.php',campos,'formSugestao',mensagem);
}

function setarVoceFaz(){
	campos = "nomeVoceFaz="+encodeURI(document.getElementById('nomeVoceFaz').value);
	campos += "&emailVoceFaz="+encodeURI(document.getElementById('emailVoceFaz').value);
	campos +="&sugestaoVoceFaz="+encodeURI(document.getElementById('sugestaoVoceFaz').value);
}

function submeterContato(){
	if(tiraEspaco(document.getElementById('nomeContato').value) == ""){	
		alert("Informe o nome.");
		document.getElementById('nomeContato').focus();
		return;
	}
	if(document.getElementById('emailContato').value == ""){
		alert("Informe o e-mail.");
		document.getElementById('emailContato').focus();
		return;	
	}else{	
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailContato').value))){ 
			alert("E-mail com formato correto");
			document.getElementById('emailContato').focus(); 
	   	    return;
	    }
	} 	
	if(tiraEspaco(document.getElementById('comentarioContato').value) == ""){	
		alert("Informe a mensagem.");
		document.getElementById('comentarioContato').focus();
		return;
	}	
	setarCamposContato();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:300px;float:center"><br><br><br><br><br><br><br><br><br><br><img src=img/loading_bm.gif border=0><br>Enviando...</div>'
	enviarForm('ler_pagina_remota_post.php',campos,'contato',mensagem);
}
function setarCamposContato(){
	campos = "nomeContato="+encodeURI(document.getElementById('nomeContato').value);
	campos += "&emailContato="+encodeURI(document.getElementById('emailContato').value);
	campos +="&comentarioContato="+document.getElementById('comentarioContato').value;
}
