choppfest = {

	enviaPG1 : function(){
		var erro = '';
		var nome = document.form1.nome.value;
		var sexo = FuncoesGerais.RetornaValorRadio(document.form1.radioSexo);
		var cpf = document.form1.cpf.value;
		var rg = document.form1.rg.value;
		var nasc = document.form1.ano.value + '-' + document.form1.mes.value + '-' + document.form1.dia.value;
		var email = document.form1.email.value;
		var endereco = document.form1.endereco.value;
		var numero = document.form1.numero.value;
		var bairro = document.form1.bairro.value;
		var estado = document.form1.dropEstado.value;
		var cidade = document.form1.dropCidade.value;
		var cep = document.form1.cep.value;
		
		if(nome=='')
			erro += "Nome<br>";
		if(sexo=='')
			erro += "Sexo<br>";
		if(FuncoesGerais.checaCPF(cpf)==0)
			erro += "CPF<br>"
		if(rg=='' || isNaN(rg))
			erro += "RG<br>";
		if(document.form1.dia.value>31 || document.form1.dia.value<1 || document.form1.mes.value>12 || document.form1.mes.value<1 || document.form1.ano.value<1900 || document.form1.ano.value>2006 || nasc.length<8 || document.form1.ano.value=='' || isNaN(document.form1.ano.value) || document.form1.mes.value=='' || isNaN(document.form1.mes.value) || document.form1.dia.value=='' || isNaN(document.form1.dia.value))
			erro += "Nascimento<br>";
		if(FuncoesGerais.ValidaEmail(email)==0)
			erro += "E-mail<br>"
		if(endereco=='')
			erro += "Endere&ccedil;o<br>";
		if(numero=='')
			erro += "N&uacute;mero<br>";
		if(bairro=='')
			erro += "Bairro<br>";
		if(estado=='')
			erro += "Estado<br>";
		if(cidade=='')
			erro += "Cidade<br>";
		if(cep=='' || isNaN(cep) || cep.length!=8)
			erro += "CEP<br>";
			
		if(erro!=''){
			document.getElementById('divErro').style.display='';
			document.getElementById('spanErroTexto').innerHTML= erro;
			document.getElementById('dropCidade').style.display='none';
			document.getElementById('dropEstado').style.display='none';
		}else{
			document.getElementById('Link_PG1').className = 'red';
			document.getElementById('Link_PG3').className = 'red';
			document.getElementById('Link_PG2').className = 'cblack';
			document.getElementById('DivPG1').style.display='none';
			document.getElementById('DivPG3').style.display='none';
			document.getElementById('DivPG2').style.display='';
		}
	},
	
	voltarPG1 : function(){
		document.getElementById('DivPG2').style.display='none';
		document.getElementById('DivPG3').style.display='none';
		document.getElementById('DivPG1').style.display='';
		document.getElementById('Link_PG2').className = 'red';
		document.getElementById('Link_PG3').className = 'red';
		document.getElementById('Link_PG1').className = 'cblack';
	},
	
	enviaPG2 : function(){
		var erro = '';
		var filhos = FuncoesGerais.RetornaValorRadio(document.form1.filhos);
		var login = document.form1.login.value;
		var senha = document.form1.senha.value;
		var senhaConf = document.form1.senhaConf.value;
		
		if(filhos=='')
			erro += "Possui filhos?<br>";
		if(document.form1.telF.value.length!=8 || document.form1.dddF.value.length!=2 || document.form1.dddF.value=='' || isNaN(document.form1.dddF.value) || document.form1.telF.value=='' || isNaN(document.form1.telF.value))
			erro += "Telefone<br>";
		if(login=='')
			erro += "Login<br>";
		if(senha=='' || senha.length<6)
			erro += "Senha<br>";
		if(senha!=senhaConf)
			erro += "Confirmar Senha<br>";
			
		if(erro!=''){
			document.getElementById('divErro').style.display='';
			document.getElementById('spanErroTexto').innerHTML= erro;
			document.getElementById('dropCidade').style.display='none';
			document.getElementById('dropEstado').style.display='none';
			document.getElementById('estadoCivil').style.display='none';
		}else{
			document.getElementById('DivPG1').style.display='none';
			document.getElementById('DivPG2').style.display='none';
			document.getElementById('DivPG3').style.display='';
			document.getElementById('Link_PG1').className = 'red';
			document.getElementById('Link_PG2').className = 'red';
			document.getElementById('Link_PG3').className = 'cblack';
		}
	},
	
	voltarPG2 : function(){
		document.getElementById('DivPG1').style.display='none';
		document.getElementById('DivPG3').style.display='none';
		document.getElementById('DivPG2').style.display='';
		document.getElementById('Link_PG1').className = 'red';
		document.getElementById('Link_PG3').className = 'red';
		document.getElementById('Link_PG2').className = 'cblack';
	},
	
	envia : function(){
		var erro = '';
		var escolhe = FuncoesGerais.RetornaValorRadio(document.form1.escolhe);
		var preferecia = FuncoesGerais.RetornaValorRadio(document.form1.preferecia);
		//var marca = FuncoesGerais.RetornaValorRadio(document.form1.marca);
		var aceito = FuncoesGerais.RetornaValorCheckUnico(document.form1.de_acordo);
		var sms = FuncoesGerais.RetornaValorCheckUnico(document.form1.sms);
		
		//document.form1.dia.value>32 || document.form1.dia.value<=0 || document.form1.mes.value>13 || document.form1.mes.value<=0 || 
		if(escolhe=='')
			erro += "Como escolhe o bar?<br>";
		if(preferecia=='')
			erro += "Prefer&ecirc;ncia<br>";
		/*if(marca=='')
			erro += "Qual &eacute; a marca do Chopp que manda voc&ecirc; para a choppfest?<br>";*/
		if(aceito==0)
			erro += "Estou de acordo com o regulamento<br>";
		if(sms==1 &&  (document.form1.operadora.value=='' || document.form1.telC.value.length!=8 || document.form1.dddC.value.length!=2 || document.form1.dddC.value=='' || isNaN(document.form1.dddC.value) || document.form1.telC.value=='' || isNaN(document.form1.telC.value)))
			erro += "Celular e Operadora<br>";
		
			
		if(erro!=''){
			document.getElementById('divErro').style.display='';
			document.getElementById('spanErroTexto').innerHTML= erro;
			document.getElementById('dropCidade').style.display='none';
			document.getElementById('dropEstado').style.display='none';
			document.getElementById('estadoCivil').style.display='none';
		}else{
			document.form1.hidValida.value = 'ok';
			document.form1.submit();
		}
		
	},
	
	fechaErro : function(){
		document.getElementById('divErro').style.display='none';
		document.getElementById('divSucesso').style.display='none';
		if(document.getElementById('dropCidade')){
			document.getElementById('dropCidade').style.display='';
			document.getElementById('dropEstado').style.display='';
			document.getElementById('estadoCivil').style.display='';
		}
	},
	
	fechaErroCadastre : function(){
		document.getElementById('divErro').style.display='none';
	},
	
	divBar : 'divSaoPaulo',
	pgAtual : 1,
	totItens : 0,
	div : '',
	linkBar : 'imgLinkSP',
		
	abreListaBares : function(idDivBar,img,idLinkBar){
		document.getElementById(this.divBar).style.display='none';
		if(document.getElementById(idDivBar)){
			this.divBar = idDivBar;
			this.div = document.getElementById(this.divBar).getElementsByTagName('div');
			this.totItens = this.div.length;
			this.pgAtual = 1;
			this.mostraBares(1);
			document.getElementById(this.divBar).style.display = '';
			document.getElementById('imgTit').style.display = '';
			document.getElementById('imgTit').src = '_IMG/' + img;
			if(this.linkBar!='')
				document.getElementById(this.linkBar).src = document.getElementById(this.linkBar).src.replace('on','off');
			this.linkBar = idLinkBar;
			if(this.linkBar!='')
				document.getElementById(this.linkBar).src = document.getElementById(this.linkBar).src.replace('off','on');
		}
	},
	
	outrosBares : function(idDivBar){
		this.abreListaBares(idDivBar,'tit_bares_outras_top.gif','');
	},
	
	mostraBares : function(pg){
		this.pgAtual=pg;
		for(i=0;i<this.totItens;i++){
			if(i>=((this.pgAtual-1) * 4) && i<(this.pgAtual*4))
				this.div[i].style.display = '';
			else
				this.div[i].style.display = 'none';
		}
		document.getElementById('divPaginacao').innerHTML='';
		if(this.totItens/4>1)
			this.montaPaginacao();
	},
	
	montaPaginacao : function(){
		if (this.pgAtual!=1)
			document.getElementById('divPaginacao').innerHTML = '<a href="javascript:choppfest.mostraBares(' + (this.pgAtual-1) +');">&lt;</a>';

		var quadrante = this.retornaQuadrante();
		for(i=0;i<Math.ceil(this.totItens/4);i++){
			if(i+1>=quadrante && i+1<=quadrante+4){
				if(this.pgAtual-1==i)
					document.getElementById('divPaginacao').innerHTML +='<a class="red" href="javascript:choppfest.mostraBares(' + (i+1) +');">' + (i+1) +'</a>'
				else
					document.getElementById('divPaginacao').innerHTML +='<a href="javascript:choppfest.mostraBares(' + (i+1) +');">' + (i+1) +'</a>'
					
			}
		}
		
		if (this.pgAtual!=Math.ceil(this.totItens/4))
			document.getElementById('divPaginacao').innerHTML += '<a href="javascript:choppfest.mostraBares(' + (this.pgAtual+1) +');">&gt;</a>';
	},
	
	retornaQuadrante : function(){	
		for(x=1;x<Math.ceil(this.totItens/4)+1;x=x+4){
			if(this.pgAtual>=x && this.pgAtual<x+4){
				return x;
				x=tot_paginas;
			}
		}
	}
	
	

}

/*

MontaNumeracao : function(){
		var conteudo = '';
		
		if (Opiniao.Pagina!=1)
			FuncoesGerais.AlteraDisplay('voltar','');
		else
			FuncoesGerais.AlteraDisplay('voltar','none');
		
		Quadrante = Opiniao.RetornaQuadrante();
		for (cont=0;cont<Opiniao.NumPaginas;cont++){
			nummostra = cont+1;
			if(nummostra>=Quadrante && nummostra<=Quadrante+7){
				if (parseInt(nummostra)==parseInt(Opiniao.Pagina)){
					if ((Quadrante-1) == cont){
						conteudo += '<li style="background: none;"><a class="number over">'+nummostra+'</a></li>';
					}else{
						conteudo += '<li><a class="number over">'+nummostra+'</a></li>';
					}
					//conteudo += '<div id="num2">'+nummostra+'</div>' ;
				}else{
					if ((Quadrante-1) == cont){
						conteudo += '<li style="background: none;"><a href="javascript:Opiniao.ControlaTabelaMensagens('+nummostra+')" class="number">'+nummostra+'</a></li>';
					}else{
						conteudo += '<li><a href="javascript:Opiniao.ControlaTabelaMensagens('+nummostra+')" class="number">'+nummostra+'</a></li>';
					}
					//conteudo += '<div id="num"><a class="linkbranco" href="javascript:Opiniao.ControlaTabelaMensagens('+nummostra+')">'+nummostra+'</a></div>';
				}
			}
			
		}
		
		if (Opiniao.Pagina!=Math.ceil(Opiniao.NumPaginas))
			FuncoesGerais.AlteraDisplay('avant','');
		else
			FuncoesGerais.AlteraDisplay('avant','none');
		
		document.getElementById('TdPgNumeracao').innerHTML = conteudo;
	},
	
	RetornaQuadrante : function(){	
		for(x=1;x<Math.ceil(parseInt(Opiniao.NumPaginas))+1;x=x+8){
			if(Opiniao.Pagina>=x && Opiniao.Pagina<x+8){
				return x;
				x=tot_paginas;
			}
		}
	},*/