/*

-------------------------------------------------------------------------------------------------------------------

                                    PORTAL CATALÃO INTERNET SERVICES LTDA

                                         suporte@portalcatalao.com.br

                                               64 3411 - 0748



           Copyright - Proibida cópia ou reprodução total ou parcial de qualquer conteúdo deste site

-------------------------------------------------------------------------------------------------------------------

*/



statusContaFlutuante = false;

function contaFlutuante(id, acao){

	var obj = document.getElementById(id);

	var objFlutuante = document.getElementById("contaFlutuante");



	// Pega as caracteristicas da dimensão da tela

	var esq = calcularPosJanela(obj,'offsetLeft');

	var cima = calcularPosJanela(obj,'offsetTop');



	objFlutuante.style.left = (esq-111)+"px";

	objFlutuante.style.top = (cima+48)+"px";

	

	if (statusContaFlutuante){

		statusContaFlutuante = false;

		objFlutuante.style.display = 'none';

	} else {

		statusContaFlutuante = true;

		objFlutuante.style.display = 'block';

	}

}



function menu(obj, on, cor){

	if (on) obj.style.backgroundColor=cor;

	else obj.style.backgroundColor='';

}



function menuLink(url){

	window.location=url;

}



function menuTopo(obj, acao){

	if (acao) obj.style.backgroundImage='url(imagens/fundo_transparente_white.png)';

	else obj.style.backgroundImage='';

}



function carregaBannerFlutuante(visivel, id, imgFlash, largura, altura, deslocamentoX, deslocamentoY){

	if (visivel){

		var obj = document.getElementById(id);



		if (document.getElementById(id+"Flutuante") == null)

			criarDiv(id+"Flutuante", "janelaFlutuante");

			

		var objFlutuante = document.getElementById(id+"Flutuante");

	

		// Pega as caracteristicas da dimensão da tela

		var esq = calcularPosJanela(obj,'offsetLeft');

		var cima = calcularPosJanela(obj,'offsetTop');

		

		objFlutuante.style.left = (deslocamentoX+esq)+"px";

		objFlutuante.style.top = (deslocamentoY+cima)+"px";

		

		if (strpos(imgFlash, '.swf') != false)		

			objFlutuante.innerHTML = exibeFash2(imgFlash, largura, altura, 'transparent');

		else

			objFlutuante.innerHTML = "<img src='"+imgFlash+"'>";

	} else {

		var tmpObj = document.getElementById(id+"Flutuante");

		tmpObj.innerHTML = "";

		tmpObj.style.left = -500;

		tmpObj.style.top = -500;

		tmpObj.style.backgroundColor = "red";

	}

}



function carregaCinema(cinemaTitulos, cinemaImgs, data, cinemaSala){

	dCinema = document.getElementById("divCinema");



	var tam = 1;

	var iNoticiaDestaqueAnimaTempo2 = setInterval(

		function() {			

			if (parseInt(tam) < cinemaTitulos.length){

				dCinema.innerHTML = '<div class="destaques3-cinema-topic"><a href="noticias/cinema,CN.rb" class="link_cinza3">CINEMA</a></div><div class="destaques3-cinema-titulo cor_blue2">Acompanhe os filmes da semana no Cine Lumi&egrave;re:</div><div class="destaques3-cinema-img"><a href="noticias/cinema,CN.rb"><img src="'+cinemaImgs[tam]+'" width="200" height="74" border="0" /></a></div><div class="destaques3-cinema-img"><a href="noticias/cinema,CN.rb"><img src="imagens/img_cinema_sala'+cinemaSala[tam]+'.png" width="200" height="31" border="0" /></a></div><div class="destaques3-cinema-descricao"><div class="destaques3-cinema-descricao-titulo"><a href="noticias/cinema,CN.rb" class="link_cinza">'+cinemaTitulos[tam]+'</a></div><div class="destaques3-cinema-descricao-data">em cartaz at&eacute; '+data+'</div></div>';

	

				tam ++;

			} else if (parseInt(tam) >= 3){

				tam = 0;

			}

		}, 5000

	);

}



// ============================================================================

// NOVO PORTAL

// ----------------------------------------------------------------------------

function noticiasDest(obj, statusAnimacao, pos, img){



	if (posAtual != pos){

	

		posAtual = pos;

//		if (document.getElementById("divNoticiaDestaque") == null)

//			criarDiv("divNoticiaDestaque", "destaques2-noticia-destaque");



		if (document.getElementById("divNoticiaDestaque") != null){

			this.ativaAnimacao = statusAnimacao;

			

			var dNoticiaDestaque = document.getElementById("divNoticiaDestaque");

			var iNoticiaDestaque = document.getElementById("imgNoticiaDestaque");

			var cNoticiaDestaque = document.getElementById("categoriaNoticiaDestaque["+pos+"]");

			var tNoticiaDestaque = document.getElementById("tituloNoticiaDestaque["+pos+"]");

			

			// Pega as caracteristicas da dimensão da tela

			var esq = calcularPosJanela(obj,'offsetLeft');

			var cima = calcularPosJanela(obj,'offsetTop');

			

			if (esq > 0 && cima > 0){			

				dNoticiaDestaque.style.left = (esq-87)+"px";

				dNoticiaDestaque.style.top = (cima-8)+"px";

				dNoticiaDestaque.style.display = "block";

			}

		

			iNoticiaDestaque.style.filter = "alpha(opacity=0)";

			iNoticiaDestaque.style.opacity = ".0";

			

			iNoticiaDestaque.src = anims[pos].src;

	

			// faz animacao na imagem

			if (navigator.userAgent.search("MSIE") != -1) var velocidade = 20;

			else var velocidade = 1;

	

			var tam = 1;

			var iNoticiaDestaqueAnimaTempo = setInterval(

				function() {

					tam += parseInt(velocidade);

					if (parseInt(tam) < 99){

						iNoticiaDestaque.style.filter = "alpha(opacity="+tam+")";

						iNoticiaDestaque.style.opacity = "."+tam;

					} else if (parseInt(tam) > 99){

						tam = 99;

						iNoticiaDestaque.style.filter = "alpha(opacity="+tam+")";

						iNoticiaDestaque.style.opacity = "."+tam;

						

						clearInterval(iNoticiaDestaqueAnimaTempo);

					}

	

				}, 1

			);

	

			var texto = tNoticiaDestaque.innerHTML.replace("link_preto", "link_azul2");

			

			dNoticiaDestaque.innerHTML = '<div class="destaques2-noticia-destaque-categoria">'+cNoticiaDestaque.innerHTML+'</div><div class="destaques2-noticia-destaque-titulo cor_blue2">'+texto+'</div>';

		}

	}



}



statusComboBox = Array();



function combobox(obj, idNovo, opcoes, links, input){



	if (!statusComboBox[idNovo]){



		statusComboBox[idNovo] = true;

		

		if (document.getElementById(idNovo) == null)

			criarDiv(idNovo, "combobox");

	

		var objCombo = document.getElementById(idNovo);



		// Pega as caracteristicas da dimensão da tela

		objCombo.style.left = calcularPosJanela(obj,'offsetLeft')+"px";

		objCombo.style.top = (calcularPosJanela(obj,'offsetTop') + obj.offsetHeight - 3)+"px";

		objCombo.style.width = obj.offsetWidth;

//alert(objCombo.style.left + ", "+ objCombo.style.top + ", " + objCombo.style.width);

		objCombo.style.display = "block";



		var opcoesStr = '';

		var opcoesStrOnMouseMove = "this.style.backgroundColor='#F7F7F7'";

		var opcoesStrOnMouseOut = "this.style.backgroundColor=''";

		

		for (var i=0; i<opcoes.length; i++){

			if (i < links.length){

				if (input != ""){

					var opcoesStrOnClick = "document.getElementById('"+input+"').value = '"+links[i]+"'; "+obj.id+".innerHTML = '"+opcoes[i]+"'; comboboxAnimaOut('"+idNovo+"');";

				} else {

					var opcoesStrOnClick = "window.location='"+links[i]+"'";

				}

				

				opcoesStr += '<div class="comboboxOpcoes" onmousemove="'+opcoesStrOnMouseMove+'" onmouseout="'+opcoesStrOnMouseOut+'" onclick="'+opcoesStrOnClick+'">'+opcoes[i]+'</div>';

			}

		}

		var alto = opcoes.length*29;

		

		

		objCombo.innerHTML = '<div id="'+idNovo+'Opc" style="position:absolute;width:'+obj.offsetWidth+'px;height:200px; margin:-'+alto+'px -'+obj.offsetWidth+'px -200px 0px;clip: rect('+alto+'px '+obj.offsetWidth+'px 200px 0px);"><div style="background-color:#FCFCFC;"><div style="background:url(imagens/borda_top.png) repeat-x top;"><div style="background:url(imagens/borda_bottom.png) repeat-x bottom;"><div style="background:url(imagens/borda_esq.png) repeat-y left;"><div style="background:url(imagens/borda_dir.png) repeat-y right;"><div style="background:url(imagens/borda_top_dir.png) no-repeat right top;"><div style="background:url(imagens/borda_bottom_dir.png) no-repeat right bottom;"><div style="background:url(imagens/borda_bottom_esq.png) no-repeat left bottom;"><div style="background:url(imagens/borda_top_esq.png) no-repeat left top;"><div style="background:url(imagens/borda_top_esq.png) no-repeat left top; padding:3px 0px 0px 0px;">'+opcoesStr+'<div><img src="imagens/nada.gif" height="1" width="1"></div></div></div></div></div> </div></div> </div></div></div></div>';



		if (navigator.userAgent.search("MSIE") != -1) comboboxAnima(idNovo+'Opc', alto, 1, 5);

		else comboboxAnima(idNovo+'Opc', alto, 1, 1);

		

			

	} else {

		statusComboBox[idNovo] = false;

	

		var objCombo = document.getElementById(idNovo);

		

		objCombo.innerHTML = "";

		objCombo.style.display = "none";



	}

}



function comboboxAnima(objeto, inicio, tempoMs, tempoPx){

	

	outra = document.getElementById(objeto);

	var tam = inicio;

	   var comboboxAnimaTempo = setInterval(

			function() {

					tam -= parseInt(tempoPx);

					if (parseInt(tam) > 0){

						outra.style.marginTop = "-"+tam+"px";

						outra.style.clip = "rect("+tam+"px, 251px, 200px, 0px)";

					} else if (parseInt(tam) < 0){

						tam = 0;

						outra.style.marginTop = "-"+tam+"px";

						outra.style.clip = "rect("+tam+"px, 251px, 200px, 0px)";

						

						clearInterval(comboboxAnimaTempo);

					}

			}, tempoMs);

}



function comboboxAnimaOut(objeto, fim, tempoMs, tempoPx){

		statusComboBox[objeto] = false;

	

		var objCombo = document.getElementById(objeto);

		

		objCombo.innerHTML = "";

		objCombo.style.display = "none";

}



var posAtual;

var frame=0;

var segundos = 5;

var timeout_state=null;

ativaAnimacao = true;



function noticiasDestAnimacao() {



	if (this.ativaAnimacao){

		noticiasDest(document.getElementById("tdNoticiaDestaque["+this.frame+"]"), true, this.frame, anims[this.frame].src);

	

		this.frame=this.frame+1;

		if (this.frame>(anims.length-1)) this.frame=0;

		timeout_state=setTimeout("noticiasDestAnimacao()",1000*segundos);

	}



}





// ============================================================================

// Impede a cópia de conteudo do site

// ----------------------------------------------------------------------------

/*

Inicialmente é usado no noticias

*/



function aniversarioAtivar(etapa){

	if (etapa == 1){

		document.getElementById('CadastroSim').style.display='none';

		document.getElementById('CadastroNao').style.display='none';

		document.getElementById('CadastroPublicar').style.display='block';

	} else if (etapa == 2){

		document.getElementById('CadastroSim').style.display='block';

		document.getElementById('CadastroNao').style.display='none';

	} else if (etapa == 3){

		document.getElementById('CadastroSim').style.display='none';

		document.getElementById('CadastroNao').style.display='block';

	}

}



function copyright(){

	alert("Prezado leitor,\nNão é permitida a utilização desse conteúdo para fins comerciais e/ou profissionais. Para comprar ou obter autorização de uso desse conteúdo, entre em contato com a Agência do Portal Catalão pelo e-mail: suporte@portalcatalao.com.br");

}



// exibe a mensagem de alerta ao dar ctrl-c ou ctrl-a em browsers não-IE

if ((document.getElementById || document.layers) && (!document.all)) {

	document.onkeypress = function (evt) {

		var r = '';

		var ctrl = 0;

		

		if (document.getElementById && (!document.all)) {

			ctrl = evt.ctrlKey;

		} else if (document.layers) {

			ctrl = Event.CONTROL_MASK;

		} 

	

		r = String.fromCharCode(evt.which).toUpperCase();    

		

		if (ctrl){

			if (r=='C'){

				alert(message);

			}

		}

	}

}



// ============================================================================

// Configura botão de fechar popUp em Flash

// ----------------------------------------------------------------------------

/*

É usado no Portal Catalão, Notícias e Festas

*/

function popUpFlutuante(numero){

	if (numero == null) numero = "";

	

	var popUp = document.getElementById("divPopUpFlutuante"+numero);

	popUp.style.display = "none";

}





// ============================================================================

// Chama Flash

// ----------------------------------------------------------------------------

/*

É usado para chamar os flash, evitando o problema do flash no IE

*/



function exibeFash(swf, width, height, wmode, cache){

	noCache = cache || cache == undefined ? "" : "?" + new Date();

	if (wmode == "" || wmode == undefined) wmode = "transparent";

	//wmode = wmode || wmode == undefined ? "transparent" : "opaque";



	monta_swf = "";

	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";

	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";

	monta_swf += "<param name=\"quality\" value=\"high\" />";

	//monta_swf += "<param name=\"menu\" value=\"0\" />";

	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";

	monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\""+ wmode +"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";

	monta_swf += "</object>";

	

	document.write(monta_swf);

}



function exibeFash2(swf, width, height, wmode, cache){

	noCache = cache || cache == undefined ? "" : "?" + new Date();

	if (wmode == "" || wmode == undefined) wmode = "transparent";

	//wmode = wmode || wmode == undefined ? "transparent" : "opaque";



	monta_swf = "";

	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";

	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";

	monta_swf += "<param name=\"quality\" value=\"high\" />";

	//monta_swf += "<param name=\"menu\" value=\"0\" />";

	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";

	monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\""+ wmode +"\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";

	monta_swf += "</object>";

	

	return (monta_swf);

}

		

// ============================================================================

// Verifica Navegador

// ----------------------------------------------------------------------------

/*

É usado na parte de cadastro de usuário.

A chamada deste método está no onload do cidades.js

*/

function verificaNavegador(){

	var divN = document.getElementById("telaNavegador");

	if(navigator.appName.indexOf('Internet Explorer')>0){

		divN.style.display = "none";

	} else {

		divN.style.display = "block";

	}

}

		

// ============================================================================

// Anima Janela em DIV

// ----------------------------------------------------------------------------

/*

No logal que irá chamar a função animaJanela() deverá ser declarada

as variáveis abaixo:

*/

var animaJanela_numLeft=parseInt(50);

var animaJanela_numTop=parseInt(50);

var animaJanela_numWidth=parseInt(0);

var animaJanela_numHeight=parseInt(0);



var animaJanela_velocidade;



function animaJanela(nomeObj) {

	// Prepara o Obj que será manipulado

	var obj =  document.getElementById(nomeObj);



	// Atribui valores a janela caso não tenha sido estabelecido a posição

	if (obj.style.left == 0) obj.style.left = parseInt(numLeft);

	if (obj.style.top == 0) obj.style.top = parseInt(numTop);

	if (obj.style.width == 0) obj.style.width = parseInt(numWidth);

	if (obj.style.height == 0) obj.style.height = parseInt(numHeight);

	

	if ((parseInt(obj.style.width) <= 70) && (parseInt(obj.style.height) <= 80) && (parseInt(obj.style.left) >= 10) && (parseInt(obj.style.top) >= 10)){

		animaJanela_numLeft-=5;

		obj.style.left=animaJanela_numLeft + "%";

		

		animaJanela_numTop-=5;

		obj.style.top=animaJanela_numTop + "%";

		

		animaJanela_numWidth+=10;

		obj.style.width=animaJanela_numWidth + "%";

		

		animaJanela_numHeight+=10;

		obj.style.height=animaJanela_numHeight + "%";



		animaJanela_velocidade=window.setTimeout("animaJanela('"+nomeObj+"');",1);

	}

}



// ============================================================================

// Criar Janela Transparente

// ----------------------------------------------------------------------------



function criarDiv(nomeDiv, classDiv){

	var divX = document.createElement('div');

	divX.className = classDiv;

	divX.setAttribute('id', nomeDiv);

	

	document.body.appendChild(divX);

}



function calcularPosJanela(campo, atributo) {

	var posicao = 0;

	while(campo) {

		posicao += campo[atributo];

		campo = campo.offsetParent;

	}

	return posicao;

}





// ============================================================================

// portal/cadastrar.php

// ----------------------------------------------------------------------------



// Função usada no Cadastrar do Portal

function portalCadastrarCheck(acao) {

	// Pega checks

	var checkPortal = document.getElementById("portal_servicos_portal");

	var checkClass = document.getElementById("portal_servicos_classificados");

	

	// Pega div's

	var divPessoais = document.getElementById("cadPessoais");

	var divPerfil = document.getElementById("cadPerfil");

	var divAutenticacao = document.getElementById("cadAutenticacao");

	

	// Personalizando os checkbox

	if (checkClass.checked && acao == 2) checkPortal.checked = "check";

	if (!checkPortal.checked && acao == 1) checkClass.checked = "";

	

	// Status da visibilidade dos campos

	if (checkPortal.checked || checkClass.checked){

		divPessoais.style.display = "block";

		divPerfil.style.display = "block";

		divAutenticacao.style.display = "block";

	} else {

		divPessoais.style.display = "none";

		divPerfil.style.display = "none";

		divAutenticacao.style.display = "none";

	}

	

}



// Configura campos de país, estado, cidades

function portalCadastrarPais(pais, tipo){

	if (pais == ""){

		pais2 = document.getElementById("portal_assine_pais2");	

		pais2.disabled = "";

		pais2.style.display = "block";

		

		uf2 = document.getElementById("portal_assine_uf2");

		uf2.disabled = "";

		uf2.style.display = "block";

		

		cidade2 = document.getElementById("portal_assine_cidade2");

		cidade2.disabled = "";

		cidade2.style.display = "block";

		

		uf1 = document.getElementById("portal_assine_uf1");

		uf1.disabled = "disabled";

		uf1.style.display = "none";

		uf1.value = "";

		

		cidade1 = document.getElementById("portal_assine_cidade1");

		cidade1.disabled = "disabled";

		cidade1.style.display = "none";

		cidade1.value = "";

		

		if (tipo == "class"){

			pais2.disabled = "disabled";

			uf2.disabled = "disabled";

			cidade2.disabled = "disabled";

		}

		

		if (tipo == "editar"){		

			cidade3 = document.getElementById("portal_assine_cidade3");

			cidade3.disabled = "disabled";

			cidade3.style.display = "none";

		}

		

	} else {

		uf1 = document.getElementById("portal_assine_uf1");

		uf1.disabled = "";

		uf1.style.display = "block";

		

		cidade1 = document.getElementById("portal_assine_cidade1");

		cidade1.style.display = "block";

		

		pais2 = document.getElementById("portal_assine_pais2");	

		pais2.disabled = "disabled";

		pais2.style.display = "none";

		pais2.value = "";

		

		uf2 = document.getElementById("portal_assine_uf2");

		uf2.disabled = "disabled";

		uf2.style.display = "none";

		uf2.value = "";

		

		cidade2 = document.getElementById("portal_assine_cidade2");

		cidade2.disabled = "disabled";

		cidade2.style.display = "none";

		cidade2.value = "";

	}

}





// ============================================================================

// Portal Festas: animação de foto (Metodo 1 de 2)



// Para animação 1

var tempAnimaFoto1 = 0;

var contAnimaFoto1 = 0;



// Para animação 2

var tempAnimaFoto2 = 0;

var contAnimaFoto2 = 0;



function animaFoto(codAnimacao, img, foto1, foto2, foto3, foto4){

	// Coloca fotos em array

	var fotos = Array(foto1, foto2, foto3, foto4);

	

	// Recupera objeto

	var imgTmp = document.getElementById(img);



	// Controla Animação

	if ((codAnimacao == 1 && contAnimaFoto1 < fotos.length) ||

	 	(codAnimacao == 2 && contAnimaFoto2 < fotos.length)){

		

		// Define no novo src da imagem

		if (codAnimacao == 1) imgTmp.src = fotos[contAnimaFoto1];

		if (codAnimacao == 2) imgTmp.src = fotos[contAnimaFoto2];

		

		// Chama recursao para mudar de foto

		if (codAnimacao == 1) tempAnimaFoto1 = setTimeout("animaFoto(1, '"+img+"', '"+foto1+"', '"+foto2+"', '"+foto3+"', '"+foto4+"');",2000);

		if (codAnimacao == 2) tempAnimaFoto2 = setTimeout("animaFoto(2, '"+img+"', '"+foto1+"', '"+foto2+"', '"+foto3+"', '"+foto4+"');",4000);

		

		// Coloca efeito na foto

		if (codAnimacao == 1){

			// Inicializa a foto como tranparente

			imgTmp.style.filter = "alpha(opacity=0)";

			imgTmp.style.opacity = ".0";

			

			efeitoAnimaFoto(img, 0);

		}

		

		if ((codAnimacao == 1) && contAnimaFoto1 >= (fotos.length-1)) contAnimaFoto1 = 0;

		else if (codAnimacao == 1) contAnimaFoto1 ++;

		

		if ((codAnimacao == 2) && contAnimaFoto2 >= (fotos.length-1)) contAnimaFoto2 = 0;

		else if (codAnimacao == 2) contAnimaFoto2 ++;

		

	} else {

		if (codAnimacao == 1) clearTimeout(tempAnimaFoto1);

		if (codAnimacao == 1) contAnimaFoto1 = 0;

		

		if (codAnimacao == 2) clearTimeout(tempAnimaFoto2);

		if (codAnimacao == 2) contAnimaFoto2 = 0;

	}

}



// Portal Festas: animação de foto (Metodo 2 de 2)



// Para animação 1

var tempEfeitoAnimaFoto1 = 0;

var contEfeitoAnimaFoto1 = 0;



// Para animação 2

var tempEfeitoAnimaFoto2 = 0;

var contEfeitoAnimaFoto2 = 0;



function efeitoAnimaFoto(img, cont){

	// Define a nova contagem para a variavel global

	contEfeitoAnimaFoto = cont;



	// Captura Objeto

	var fP = document.getElementById(img);



	if (contEfeitoAnimaFoto < 99){

		fP.style.filter = "alpha(opacity="+contEfeitoAnimaFoto+")";

		fP.style.opacity = "."+contEfeitoAnimaFoto;

		tempEfeitoAnimaFoto = window.setTimeout("efeitoAnimaFoto('"+img+"', '"+(parseInt(contEfeitoAnimaFoto)+10)+"');",1);

	} else {

		// Configura Objeto

		fP.style.filter = "alpha(opacity=99)";

		fP.style.opacity = ".99";



		clearTimeout(tempEfeitoAnimaFoto);

	}

}



// ============================================================================

// Geral: Animacao ao passar mouse em foto muda a borda

function passarMouseFotoBordaCor(fotoP, classCorBorda){

	// Chama os objetos

	var fp = document.getElementById(fotoP);



	// Muda a cor da borda

	fp.className = classCorBorda;

}



// ============================================================================

// Portal: Mostra as últimas fotos da galeria de fotos (do sistema de notícias)

function galeriaPortalFotosNoticias(obj, qtd){

	// Esconde todos os obj	

	for (i=0;i<qtd;i++){

		// Chama os obj que não ficarão visíveis		

		var x = document.getElementById(obj.substr(0,(obj.length-1))+i);

		

		// Muda a visibilidade para não visível

		x.style.display = "none";

	}



	// Chama os obj que ficarão visíveis

	var x = document.getElementById(obj);



	// Muda a visibilidade para visível

	x.style.display = "block";

}



// ============================================================================

// PortalVideos: Configura os votos nos videos



var jaVotado = false; // varivel usada no metodo configuraVotos()



function configuraVotos(acao, pos){	

	// acao == 0: passa o mouse

	// acao == 1: volta para a qtd de estrelas original

	// acao == 2: modifica a legenda para votado

	

	if (jaVotado == false){

		if (acao == 0){

			for (i=0; i<5; i++){

				if (i <= pos) document.getElementById("estrela_"+i).src = "imagens/icon_estrelap2.png";

				else document.getElementById("estrela_"+i).src = "imagens/icon_estrelap1.png";

			}

		} else if (acao == 1){

			posOrig = document.getElementById("votosPos");

			for (i=0; i<5; i++){

				if (i <= posOrig.value) document.getElementById("estrela_"+i).src = "imagens/icon_estrelap2.png";

				else document.getElementById("estrela_"+i).src = "imagens/icon_estrelap1.png";

			}

		} else if (acao == 2){

			for (i=0; i<5; i++){

				if (i <= pos) document.getElementById("estrela_"+i).src = "imagens/icon_estrelap2.png";

				else document.getElementById("estrela_"+i).src = "imagens/icon_estrelap1.png";

			}

			document.getElementById("votosLegenda").innerHTML = "nota computada";

			jaVotado = true;

		}

	}

}



// ============================================================================

// PortalVideos: Configura os menus de opcoes dos videos



function menuVideo(acao){

	document.getElementById("telaHtml").style.display = "none";

	document.getElementById("telaLink").style.display = "none";

	document.getElementById("telaLinha").style.display = "none";

	

	if (acao != ""){

		document.getElementById(acao).style.display = "block";

		document.getElementById("telaLinha").style.display = "block";

	}

}



// ============================================================================

// PortalVideos e outros: Adiciona a pagina nos favoritos



function addFavoritos(titulo, url){

	if (isExplorer()){

		if (document.all) window.external.AddFavorite(url, titulo);

		else if (window.sidebar) window.sidebar.addPanel(titulo, url, "")

	} else alert("Pressione Ctrl+D para adicionar este site em seus Favoritos");

}



// ============================================================================

// PortalVideos e outros: Verifica se esta utilizando o IE, e usado na funcao addFavoritos



function isExplorer(){

   if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) return true;

   else if(navigator.appName == "Netscape") return false;

   else return false;   

}



// ============================================================================

// SCRIPTS EM JS -> CRIA FUNCOES PARA JS QUE EXISTE EM PHP MAIS NAO EXISTE EM JS

// ----------------------------------------------------------------------------

/*

Similar a função explode do PHP



exemplo 1: lg_explode(' ', 'Luiz Gustavo Ferreira Felício');

retorno 1: {0: 'Luiz', 1: 'Gustavo', 2: 'Ferreira', 3: 'Felício'}

exemplo 2: lg_explode('=', 'a=bc=d', 2);

retorno 2: ['a', 'bc=d']

*/



function lg_explode( delimiter, string, limit ) {

    var emptyArray = { 0: '' };

    

    if ( arguments.length < 2

        || typeof arguments[0] == 'undefined'

        || typeof arguments[1] == 'undefined' )

    {

        return null;

    }

 

    if ( delimiter === ''

        || delimiter === false

        || delimiter === null )

    {

        return false;

    }

 

    if ( typeof delimiter == 'function'

        || typeof delimiter == 'object'

        || typeof string == 'function'

        || typeof string == 'object' )

    {

        return emptyArray;

    }

 

    if ( delimiter === true ) {

        delimiter = '1';

    }

    

    if (!limit) {

        return string.toString().split(delimiter.toString());

    } else {

        var splitted = string.toString().split(delimiter.toString());

        var partA = splitted.splice(0, limit - 1);

        var partB = splitted.join(delimiter.toString());

        partA.push(partB);

        return partA;

    }

}



function strpos (haystack, needle, offset) {

    // example 1: strpos('Luiz Gustavo Ferreira Felício', 'F', 5);

    var i = (haystack + '').indexOf(needle, (offset || 0));

    return i === -1 ? false : i;

}



// ----------------------------------------------------------------------------

/*

Similar a função base64_encode do PHP



    // *     example 1: Base64.encode('luiz');

*/

function lg_array_reverse(array, preserve_keys) { 

    var arr_len = array.length, newkey = 0, tmp_arr = {}, key = '';

    preserve_keys = !!preserve_keys;

    

    for (key in array) {

        newkey = arr_len - key - 1;

        tmp_arr[preserve_keys ? key : newkey] = array[key];

    }

 

    return tmp_arr;

}



function retiraGeraNiver(id){

	var obj = document.getElementById(id);

	obj.style.display = 'none';

}



var tempoGeraNiver;

function geraNiver(mouseAtivo, id, nome, apelido, dataNasc, localizacao, linkNiver){



	if (!mouseAtivo){

		tempoGeraNiver=window.setTimeout("retiraGeraNiver('"+id+"');",1000);

	} else {



		clearTimeout(tempoGeraNiver);



		// captura foro do aniversariante

		var obj = document.getElementById(id);

		

		// calcula posicao das fotos

		var esq = calcularPosJanela(obj,'offsetLeft');

		var cima = calcularPosJanela(obj,'offsetTop');

		

		// cria div com as informacoes

		if (document.getElementById("divJanelaNiver") == null)

			criarDiv("divJanelaNiver", "janelaNiver");

		

		// gera funcao de onMouseMove da imagem

		var OnMouseMoveImg = "geraNiver(true, '" + obj.id + "', '" + nome + "', '" + apelido + "', '" + dataNasc + "', '" + localizacao + "', '" + linkNiver + "')";

		var OnMouseOutImg = "geraNiver(false, '" + obj.id + "', '" + nome + "', '" + apelido + "', '" + dataNasc + "', '" + localizacao + "', '" + linkNiver + "')";

		

		// configura nova dimensao

		var new_width = 200;

		var new_height = 200;

	

		var width = parseInt(obj.width);

		var height = parseInt(obj.height);

	

		new_height = (new_width / width) * height;

		

		if (new_height > 200)

			new_height = 200;

	

		

		if (new_width && (width < height)) {

		   new_width = (new_height / height) * width;

		} else {

		   new_height = (new_width / width) * height;

		}

		

		new_width = parseInt(new_width);

		new_height = parseInt(new_height);

		

		var imgSrc = obj.src.replace("w="+obj.width, "w="+new_width);

		var imgSrc = imgSrc.replace("h="+obj.height, "h="+new_height);

			

		// configura div

		var dJanelaNiver = document.getElementById("divJanelaNiver");

		dJanelaNiver.style.display = 'block';

		dJanelaNiver.style.left = (esq - parseInt(new_width / 3)) + 'px';

		dJanelaNiver.style.top = (cima - parseInt(new_height / 3)) + 'px';

		dJanelaNiver.style.width = (new_width + 10) + 'px';

		dJanelaNiver.style.height = (new_height + 10 + 40) + 'px';



		if (nome != apelido)

			nome = nome + " <br>(" + apelido + ")";

			

		var widthTable = 200;

		if (new_width > 200)

			widthTable = new_width;



		dJanelaNiver.innerHTML = '<table border="0" cellspacing="0" cellpadding="0" style="border:solid 3px; border-color:#89B216;background-color:#FFFFFF"><tr><td align="center" valign="middle" height="' + (new_height + 10) + '"><a href="'+linkNiver+'"><img id=' + obj.id + ' src=' + imgSrc + ' width=' + new_width +' height=' + new_height +' onmousemove="' + OnMouseMoveImg + '" onmouseout="' + OnMouseOutImg + '" border="0" hspace="2" vspace="2" /></td></tr><tr><td align="center" valign="middle" height="40"><span class="subtitulo">' + nome + '</span><br><img src="../imagens/nada.gif" width="5" height="5"><br>Aniversário: ' + dataNasc + '<br> Cidade: ' + localizacao + '<br><img src="../imagens/nada.gif" width="5" height="5"></td></tr></table>';

	}



}



 

var Base64 = {

 

	// private property

	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

 

	// public method for encoding

	encode : function (input) {

		var output = "";

		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;

		var i = 0;

 

		input = Base64._utf8_encode(input);

 

		while (i < input.length) {

 

			chr1 = input.charCodeAt(i++);

			chr2 = input.charCodeAt(i++);

			chr3 = input.charCodeAt(i++);

 

			enc1 = chr1 >> 2;

			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);

			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);

			enc4 = chr3 & 63;

 

			if (isNaN(chr2)) {

				enc3 = enc4 = 64;

			} else if (isNaN(chr3)) {

				enc4 = 64;

			}

 

			output = output +

			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +

			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

 

		}

 

		return output;

	},

 

	// public method for decoding

	decode : function (input) {

		var output = "";

		var chr1, chr2, chr3;

		var enc1, enc2, enc3, enc4;

		var i = 0;

 

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

 

		while (i < input.length) {

 

			enc1 = this._keyStr.indexOf(input.charAt(i++));

			enc2 = this._keyStr.indexOf(input.charAt(i++));

			enc3 = this._keyStr.indexOf(input.charAt(i++));

			enc4 = this._keyStr.indexOf(input.charAt(i++));

 

			chr1 = (enc1 << 2) | (enc2 >> 4);

			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);

			chr3 = ((enc3 & 3) << 6) | enc4;

 

			output = output + String.fromCharCode(chr1);

 

			if (enc3 != 64) {

				output = output + String.fromCharCode(chr2);

			}

			if (enc4 != 64) {

				output = output + String.fromCharCode(chr3);

			}

 

		}

 

		output = Base64._utf8_decode(output);

 

		return output;

 

	},

 

	// private method for UTF-8 encoding

	_utf8_encode : function (string) {

		string = string.replace(/\r\n/g,"\n");

		var utftext = "";

 

		for (var n = 0; n < string.length; n++) {

 

			var c = string.charCodeAt(n);

 

			if (c < 128) {

				utftext += String.fromCharCode(c);

			}

			else if((c > 127) && (c < 2048)) {

				utftext += String.fromCharCode((c >> 6) | 192);

				utftext += String.fromCharCode((c & 63) | 128);

			}

			else {

				utftext += String.fromCharCode((c >> 12) | 224);

				utftext += String.fromCharCode(((c >> 6) & 63) | 128);

				utftext += String.fromCharCode((c & 63) | 128);

			}

 

		}

 

		return utftext;

	},

 

	// private method for UTF-8 decoding

	_utf8_decode : function (utftext) {

		var string = "";

		var i = 0;

		var c = c1 = c2 = 0;

 

		while ( i < utftext.length ) {

 

			c = utftext.charCodeAt(i);

 

			if (c < 128) {

				string += String.fromCharCode(c);

				i++;

			}

			else if((c > 191) && (c < 224)) {

				c2 = utftext.charCodeAt(i+1);

				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));

				i += 2;

			}

			else {

				c2 = utftext.charCodeAt(i+1);

				c3 = utftext.charCodeAt(i+2);

				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));

				i += 3;

			}

 

		}

 

		return string;

	}

 

}



// ----------------------------------------------------------------------------

/*

Similar a função array_reverse do PHP



exemplo 1: array_reverse( [ 'php', '5.0', ['verde', 'vermelho'] ], true);

retorno 1: { 2: ['verde', 'vermelho'], 1: 5.0, 0: 'php'}

*/
