//---------------------------------------------------------------------------------
//Funções globais do site: www.brasiliavip.com.br
//Desenvolvido por: Helton Lídio em 06/03/2006
//Ultima atualização em: 
//E-mail: helton@brasiliavip.com.br
//MSN: hlidio@hotmail.com
//Total de Funções: 32
//---------------------------------------------------------------------------------

//---------------------------------------------------------------------------------
//Função que abre a janela para o usuário visualizar as fotos das coberturas
// passando a area e o id do evento
//---------------------------------------------------------------------------------
function vAlbum(area,id){
	var auxpag = "/web/album.asp?idarea="+area+"&id="+id
	Popup(auxpag,780,600,'yes')
}
//---------------------------------------------------------------------------------
//Função que abre a janela para o usuário comentar
// e passa o id e nome da imagem
//---------------------------------------------------------------------------------
function Comentar(id,img){
	window.open("comentario.asp?id="+id+"&img="+img+"","Comentar","toolbar=no,status=no,width=366,height=520,resizable=no");
}
//---------------------------------------------------------------------------------
//Função:Funções para Mostrar / Ocultar divs
//---------------------------------------------------------------------------------
function showHide(camada) {
	if (document.getElementById(camada).style.display == "none") document.getElementById(camada).style.display = "";
	else document.getElementById(camada).style.display = "none";
}

//---------------------------------------------------------------------------------
//Função que manda imprimir o conteúdo da tela sem o botão imprimir
//Sintaxe: Onclick="Imprimir(btn)"
//---------------------------------------------------------------------------------
function Imprimir(btn){
	document.all[btn].style.display = 'none';
	window.print();
	document.all[btn].style.display = 'inline';
}

//---------------------------------------------------------------------------------
//Função que exibe e oculta as camadas (menu)
//Sintaxe: Onclick="ExibeOculta('camada')"
//---------------------------------------------------------------------------------
var anterior = "none";
function ExibeOculta(camada){
	document.getElementById(camada).style.display = "inline";
	if(camada != anterior){
		document.getElementById(anterior).style.display = "none";
	}
	anterior = camada;
}


//---------------------------------------------------------------------------------
//Função que limita a seleção de texto no site!
//---------------------------------------------------------------------------------
function SelTexto(){
	function disableselect(e){
		return false
	}
	
	function reEnable(){
		return true
	}
	
	//Se for IE4+
		document.onselectstart = new Function ("return false")
	
	//Se for NS6
	if (window.sidebar){
		document.onmousedown = disableselect
		document.onclick = reEnable
	}
}

//---------------------------------------------------------------------------------
//Função que limita a visualização do cód. do site!
//---------------------------------------------------------------------------------
function BotaoDireito(){
	document.onkeydown = Click
	document.onmousedown = Click
	
	if (window.Event){
		document.captureEvents(Event.MOUSEUP); 
	}
	
	function nocontextmenu(){ 
		event.cancelBubble = true 
		event.returnValue = false; 
		
		return false; 
	} 
	
	function norightclick(e) { 
		if (window.Event){ 
			if (e.which == 2 || e.which == 3) 
			return false; 
		} else if (event.button == 2 || event.button == 3) { 
			event.cancelBubble = true 
			event.returnValue = false; 
			return false; 
		} 
	} 
	
	function Click(){
		if (event.ctrlKey | event.altKey | event.keyCode == 116 | event.button == 2){
			return false;
		}
	}
	
	if (document.layers) { 
		document.captureEvents(Event.MOUSEDOWN); 
	} 
	document.oncontextmenu = nocontextmenu; 
	document.onmousedown = norightclick; 
	document.onmouseup = norightclick; 
}

//---------------------------------------------------------------------------------
//Função que limita a quantidade de caracteres digitados pelo usuário!
//Sintaxe: onKeyDown="Conta(Mensagem,contador,125);" 
//Sintaxe: onKeyUp="Conta(Mensagem,contador,125);"
//---------------------------------------------------------------------------------
function Conta(txtMensagem, txtConta, limite) {
	with(document.all){
		if (txtMensagem.value.length > limite){	
			txtMensagem.value = txtMensagem.value.substring(0, limite);
		}else {
			txtConta.value = limite - txtMensagem.value.length;
		}
	}
}
//---------------------------------------------------------------------------------
//Função que limita a quantidade de caracteres iguais digitado pelo usuário!
//Sintaxe: onKeyDown="return Valida(event);
//---------------------------------------------------------------------------------
function LimitaIgual(event){
	switch(contador){
		case 1: digito = event.keyCode;
				contador++;
				return true;
				break;
		case 2:	
			if(digito == event.keyCode)
				contador++;
			else
				contador--;
			return true;
			break;
		case 3:	
			if(digito == event.keyCode){
				//alert('Somente 3 digitos iguais');
				event.ReturnCode=false;
				event.keyCode=0;
				return false;
			}else{
				contador = 1;
				return true;
			}
			break;
	}
}


//---------------------------------------------------------------------------------
//Função que adiciona o cód do smilie na mensagem
//Sintaxe: Onclick="Smilie('imagem')"
//---------------------------------------------------------------------------------
function Smilie(img,campo){
	with(document.formulario){
		campo.value = campo.value+" ["+[img]+"] "
	}
}


//---------------------------------------------------------------------------------
//Função que abre popup (janela)
//Sintaxe: Onclick = Popup('pagina.asp',300,300,'yes')
//---------------------------------------------------------------------------------
function Popup(pag,w,h,scrolbar){
	var width = w; //largura
	var height = h;//altura
	
	var left = 10; //posicao esquerda na tela
	var top = 10;  //posicao Direita na tela
	
	url = pag;
	
	window.open(url,'Publicidade','width='+width+',height='+height+', top='+top+', left='+left+',scrollbars='+scrolbar+', status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

//---------------------------------------------------------------------------------
//Função que só permite números
//Sintaxe: Onkeypress="SoNumero()"
//---------------------------------------------------------------------------------
function SoNumero(){
	if ( (window.event.keyCode >= 48) && (window.event.keyCode <= 57) ){
		return(true)
	}else{
		window.event.keyCode = 0;
		return(false);
	}
}

//---------------------------------------------------------------------------------
//Função que Formata a Data
//Sintaxe: OnKeyPress="FormataData(this.value)"
//---------------------------------------------------------------------------------
function FormatarData(campo) {
	var len = campo.value.length;
	var aux = !isNaN(campo.value.charAt(len - 1));
	
	if (aux == true) {
		if (len == 5) campo.value += "/";
		if (len == 2) campo.value += "/";
	} else {
		aux2 = campo.value;
		campo.value = aux2.substring(0,aux2.length-2);
	}
}

//---------------------------------------------------------------------------------
//Função que valida o email
//Sintaxe: Onkeydown="ValidaEmail(this.value)"
//---------------------------------------------------------------------------------
function ValidaEmail(campo){
	var i=campo.indexOf("@")
	var l=campo.length
	var j=campo.lastIndexOf(".")
	if((l<8)||(i<2)||((l-i)<5)||(j==-1)||((j-i)<3)||((l-j)<3)||((l-j)>5)){
		alert("E-Mail Inválido!")
		return(false);
	}
}


//---------------------------------------------------------------------------------
//Função que formata Valor R$
//Sintaxe: Onkeypress="FormatarValor(this.value)"
//---------------------------------------------------------------------------------
function FormatarValor(campo){
if ( (window.event.keyCode>=48) && (window.event.keyCode<=57) ){
	
	var tecla = window.event.keyCode;
	vr = campo.value;
	tammax = campo.maxLength;
	
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;
	
		if ( tam < tammax && tecla != 8 ) { tam = vr.length + 1 ; }
	
		if ( tecla == 8 ){ tam = tam - 1 ; }
	
		if ( tecla != 16 && tecla != 9 && tecla != 8 && tecla != 13 && tecla != 37 && tecla != 39 && tecla != 46 ){
			if ( tam <= 2 ) 
				campo.value = vr ; 
			
			if ( (tam > 2) && (tam <= 5) ) 
				campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; 
			
			if ( (tam >= 6) && (tam <= 8) ) 
				campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
			
			if ( (tam >= 9) && (tam <= 11) ) 
				campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
			
			if ( (tam >= 12) && (tam <= 14) ) 
				campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
			
			if ( (tam >= 15) && (tam <= 17) )
				campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
		}		
	}else{
		window.event.keyCode=0;
		return(false);
	}
}
//---------------------------------------------------------------------------------
//Função que formata data
//Sintaxe: onkeypress = formatarDAta(this);
//---------------------------------------------------------------------------------
function FormatarData(campo) {
	tecla = window.event.keyCode;
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 && tecla != 13 && tecla != 37 && tecla != 39 && tecla != 46 ){
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, tam );
		if ( tam >= 5 && tam <= 10 )
			campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); }
}

//---------------------------------------------------------------------------------
//Função que formata data
//Sintaxe: onkeypress = FormatarHora(this);
//---------------------------------------------------------------------------------
function FormatarHora(campo)
{
	var tecla = window.event.keyCode;
	vr = campo.value;
	vr = vr.replace( ":", "" );
	vr = vr.replace( ":", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 && tecla != 13 && tecla != 37 && tecla != 39 && tecla != 46 ){
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, 2 ) + ':' + vr.substr( 2, tam ); }
}

//---------------------------------------------------------------------------------
//Função que formata o numero do telefone
//Sintaxe: onkeypress = FormatarTelefone(this);
//---------------------------------------------------------------------------------
function FormatarTelefone(campo) {
	tecla = window.event.keyCode;
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	tam = vr.length;
	
	if ( tecla != 9 && tecla != 8 && tecla != 13 && tecla != 37 && tecla != 39 && tecla != 46 )
	{
		if ( tam < 2)
			campo.value = '(' + vr.substr(0,tam);
		if ( tam == 2)
			campo.value = '(' + vr.substr(0,2) + ') ';
		if ( tam > 2)
			campo.value = '(' + vr.substr(0,2) + ')' + vr.substr(2,tam);
	}
			
   }
  
//---------------------------------------------------------------------------------
//Função que formata o numero do cep
//Sintaxe: onkeypress = FormatarCep(this)
//---------------------------------------------------------------------------------   
function FormatarCEP(campo){
	var tecla = window.event.keyCode;
	vr = campo.value;
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 && tecla != 13 && tecla != 37 && tecla != 39 && tecla != 46 ) 
	{
		if (( tam > 2 ) && ( tam < 4))
	 	{campo.value = vr + '.';}

		if (( tam > 6 )  && ( tam < 8 ))
	 	{campo.value = vr + '-';}


	}
}
//---------------------------------------------------------------------------------
//Função Verifica Campo Nulo(Vazio)
//Sintaxe: onkeypress = VerificaCampo(campo,'Mensagem');
//---------------------------------------------------------------------------------
function VerificaCampo(campo){
	if(campo.value.lengh < 3 || campo.value == ""){
		alert("Verifique o preenchimento dos campos obrigatórios!\nTodos os campos precisam conter mais de 3 caracteres!")
		campo.focus();
		campo.style.background = "#BDCBDB";
		campo.style.color = "#ffffff";
		return(false);
	}
}

//---------------------------------------------------------------------------------
//Função compara os valores de 2 campos
//Sintaxe: ComparaCampo(campo1,campo2);
//---------------------------------------------------------------------------------
function ComparaCampos(campo1,campo2,msg){
	if(campo1.value != campo2.value){
		alert(msg);
		campo2.focus();
		campo1.style.background = "#BDCBDB";
		campo1.style.color = "#ffffff";
		return(false);
	}
}


//---------------------------------------------------------------------------------
//Função tem por objetivo determinar se o dado fornecido é composto apenas por espaços vazios.
//Sintaxe: onkeypress = VerificaEspaco(campo);
//--------------------------------------------------------------------------------- 
function VerificaEspaco(campo){
	DigInvalido = " ";
	SoEspacos = true;
	NRCaracteres = eval(campo +".value.length");

	for(Contador=0; Contador < NRCaracteres; Contador++){ 
		
		CaracTemp = eval(campo+".value"+".substr("+Contador+",1)");
		
		if (CaracTemp.toLowerCase() != DigInvalido.toLowerCase()){
			SoEspacos = false;
			return(false);					
		}		
	}
	if (SoEspacos == true){
		return(false);
	}					
}


//---------------------------------------------------------------------------------
//Função que valida o e-mail digitado
//Sintaxe: onChange="ValidarEmail(this);
//--------------------------------------------------------------------------------- 
function ValidarEmail(obj)
{
	var email = obj.value;
	var BadChars = "*|,\":<>[]{}`\'';()&$#% ";
	var GoodChars = "@."; 
	var posarroba = email.indexOf ('@',0);
	
	if (email.length < 6) // o email é menor que 6 caracteres
	{
		alert("\"E-mail\" inválido!"); 
		obj.focus();
		return false;
	}
	
	for (var i = 0; i < email.length; i++) 
	{
		if (BadChars.indexOf(email.charAt(i)) != -1) // Contém caracteres inválidos, badchars
		{
			alert("Seu \"E-mail\" contém caracteres inválidos!");
			obj.value = '';
			obj.focus();
			return false;
		}
	}

	for (var i = 0; i < GoodChars.length; i++) 
	{
		if (email.indexOf(GoodChars.charAt(i)) == -1) // não tem goodchars
		{
			alert("\"E-mail\" inválido!");
			obj.focus();
			return false;
		}

		if (email.indexOf(GoodChars.charAt(i),0) == 0) // começou com goodchars (. ou @)
		{
			alert("\"E-mail\" inválido!");
			obj.focus();
			return false;
		}

		if (email.lastIndexOf(GoodChars.charAt(i)) > email.length-3) //existe menos de 2 caracteres depois do ultimo goodchar
		{
			alert("\"E-mail\" inválido! Seu e-mail não deve terminar com @ ou .");
			obj.focus();
			return false;
		}
	}

	if (email.lastIndexOf('@') > email.lastIndexOf('.')) //Não tem ponto depois do arroba
	{
		alert("\"E-mail\" inválido!");
		obj.focus();
		return false;
	}

	if (email.indexOf ('@.',0) != -1 || email.indexOf ('.@',0) != -1) // . e @ colados
	{
		alert("\"E-mail\" inválido!");
		obj.focus();
		return false;
	}

	if (email.indexOf ('@',posarroba+1) != -1) // Contém mais de um " @ " 
	{
		alert("\"E-mail\" inválido!");
		obj.focus();
		return false;
	}
	
	return true;
}

//---------------------------------------------------------------------------------
//Função que exibe na tela os dados do Xml+XSL
//Sintaxe: Ranking();
//--------------------------------------------------------------------------------- 
function MostraRanking(){
	// Arquivo XML 
	var xml = new ActiveXObject("Microsoft.XMLDOM")
	xml.async = false
	xml.load("xml/rk/ranking.xml")
	
	// Arquivo XSL
	var xsl = new ActiveXObject("Microsoft.XMLDOM")
	xsl.async = false
	xsl.load("xml/rk/ranking.xsl")

	//Transformação
	document.write(xml.transformNode(xsl))
}

//---------------------------------------------------------------------------------
//  Função do editor de texto
//---------------------------------------------------------------------------------
	<!-- // load htmlarea
	_editor_url = "/admin/includes/editor/";

	// URL to html area files
	var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
	if (win_ie_ver >= 5.5) {
	  document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
	  document.write(' language="Javascript1.2"></scr' + 'ipt>');  
	} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
	// -->

//---------------------------------------------------------------------------------
//  Função que marca todos os objetos informados
//---------------------------------------------------------------------------------
function checkall(form,campo) {
	with(document.getElementById(form)) {
		for(i=0;i<elements.length;i++) {
			thiselm = elements[i];
			if(thiselm.name.substring(0,8) == campo)
			thiselm.checked = !thiselm.checked
		}
	}
}

//---------------------------------------------------------------------------------
//Função que coloca o relógio em flash sobre outras camadas!
//Sintaxe: onMouseOver="_eXp('obejto',120,200)" onMouseOut="_eXp('objeto',120,68)"
//---------------------------------------------------------------------------------

iSf_=false;
iFv_=0;
_dT=document;
_nV=navigator;
_nVM=_nV.mimeTypes;
_aPS="application/x-shockwave-flash";
function _gOJ(s){
	if(_dT.layers){
		return _dT.layers[s];
	}else if(_dT.all && !_dT.getElementById){                   
		return _dT.all[s];
	}else{
		return _dT.getElementById(s);
	}         
}
function _eXp(s,x,y){
	_o = _gOJ(s);
	_o.style.clip = 'rect(0,'+x+','+y+',0)';
}
function setTransparent(){
	return;
}
function _mFl(){                                
	_pLg = (_nVM&&_nVM[_aPS]&&_nVM[_aPS].enabledPlugin)?_nVM[_aPS].enabledPlugin:0;
	if(_pLg){
		iSf_ = true;
		iFv_ = parseInt(_pLg.description.substring(_pLg.description.indexOf(".")-1));
	}else{
		if(_nV.userAgent.indexOf("Mac")==-1){
			with(_dT){
				writeln('<scr'+'ipt language=VBScript>');
				writeln('Dim hasPlayer, playerversion ');
				writeln('hasPlayer = false ');
				writeln('playerversion = 10 ');
				writeln('Do While playerversion > 0 ');
				writeln('On Error Resume Next ');
				writeln('hasPlayer = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & playerversion))) ');
				writeln('If hasPlayer = true Then Exit Do ');
				writeln('playerversion = playerversion - 1');
				writeln('Loop');
				writeln('iFv_ = playerversion');
				writeln('iSf_ = hasPlayer');
				writeln('<\/sc' + 'ript>');
			}
		}
	}
}

_mFl();
if(iSf_ == true && iFv_ > 4)