function GetXmlHttpObject(){
	
	if (window.XMLHttpRequest) { a=new XMLHttpRequest(); } /*Objeto nativo (FF/Safari/Opera7.6+)*/
	else {  
		try { a = new ActiveXObject("Msxml2.XMLHTTP");  /*activeX (IE5.5+/MSXML2+)*/ }	 
		catch(e) {  
			try { a = new ActiveXObject("Microsoft.XMLHTTP"); /*activeX (IE5+/MSXML1)*/ }	 
			catch(e) { /* O navegador não tem suporte */ a = false; }  
		}  
	}   
	return a;  
}

function carrega_sub(id_categoria){

	xmlHttp=GetXmlHttpObject();
	url="ajax/carrega_sub.asp";
	
	url = url + "?sid=" + Math.random();
	url = url + "&id_categoria="+ id_categoria;
	
	xmlHttp.onreadystatechange = verifica_carrega_sub;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	function verifica_carrega_sub(){ 
		
		if (xmlHttp.readyState == 4) {
			document.getElementById("categoria_sub").innerHTML = xmlHttp.responseText;
			//document.getElementById("txt_sub").innerHTML = "Subcategoria:";
		}
	}

}

function validaFormFaleConosco(){
	
	//VERIFICA SE O CAMPO EXISTE NO FORMULÁRIO E CAPTURA OS VALORES DO MESMO//
	if (document.getElementById("Nome")){ 
		var nome = document.getElementById("Nome").value;
		if(nome == ""){ alert("Nome não preenchido."); document.getElementById("Nome").focus(); return false; }
	}
	if (document.getElementById("Email")){ 
		var email = document.getElementById("Email").value; 
		if(email == "" || email.match(/(\w+)@(.+)\.(\w+)$/) == null){ 
		alert("Email incorreto ou não preenchido."); document.getElementById("Email").focus(); return false; }
	}
	if (document.getElementById("Endereco")){ 
		var endereco = document.getElementById("Endereco").value; 
		if(endereco == ""){ alert("Endereço não preenchido."); document.getElementById("Endereco").focus(); return false; }
	}
	if (document.getElementById("Estado")){ 
		var estado = document.getElementById("Estado").value; 
		if(estado == ""){ alert("Estado não preenchido."); document.getElementById("Estado").focus(); return false; }
	}
	if (document.getElementById("Cidade")){ 
		var cidade = document.getElementById("Cidade").value;
		if(cidade == ""){ alert("Cidade não preenchida."); document.getElementById("Cidade").focus(); return false; }
	}
	if (document.getElementById("Bairro")){ 
		var bairro = document.getElementById("Bairro").value;
		if(bairro == ""){ alert("Bairro não preenchido."); document.getElementById("Bairro").focus(); return false; }
	}
	if (document.getElementById("TelRes")){ 
		var telRes = document.getElementById("TelRes").value;
		if(telRes.length < 14 || telRes.length > 14){ 
		alert("Telefone Residencial incorreto ou não preenchido."); document.getElementById("TelRes").focus(); return false; }
	}
	if (document.getElementById("TelCom")){ 
		var telCom = document.getElementById("TelCom").value;
		if(telCom.length < 14 || telCom.length > 14){ 
		alert("Telefone Comercial incorreto ou não preenchido."); document.getElementById("TelCom").focus(); return false; }
	}
	if (document.getElementById("TelCel")){ 
		var telCel = document.getElementById("TelCel").value;
		if(telCel.length < 14 || telCel.length > 14){ 
		alert("Telefone Celular incorreto ou não preenchido."); document.getElementById("TelCel").focus(); return false; }
	}
	if (document.getElementById("Cep")){
		var cep = document.getElementById("Cep").value;
		if(cep.length != 9){ 
		alert("CEP incorreto ou não preenchido."); document.getElementById("Cep").focus(); return false; }
	}
	if (document.getElementById("Assunto")){
		var assunto = document.getElementById("Assunto").value;
		if(assunto == ""){ alert("Assunto não preenchido."); document.getElementById("Assunto").focus(); return false; }
	}
	if (document.getElementById("Mensagem")){ 
		var mensagem = document.getElementById("Mensagem").value;
		if(mensagem == ""){ alert("Mensagem não preenchida."); document.getElementById("Mensagem").focus(); return false; }
	}
	
	xmlHttp=GetXmlHttpObject();
	url="captchacode.asp";
	
	var captchacode = document.getElementById("captchacode").value;
	
	url = url + "?sid=" + Math.random();
	url = url + "&captchacode="+ captchacode;
	
	xmlHttp.onreadystatechange = VerificaCaptchacode;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	function VerificaCaptchacode(){ 
		
		if (xmlHttp.readyState == 4) { 
		
			if(xmlHttp.responseText==0){
				alert("Código de segurança inválido ou não preenchido");
			}else{
				document.getElementById("span").value = "validado";
				document.formFaleConsoco.submit();
			}
		}
	}
}

function validaFormAssociado(){
	
	//VERIFICA SE O CAMPO EXISTE NO FORMULÁRIO E CAPTURA OS VALORES DO MESMO//
	/*if (document.getElementById("CBTri")){ 
		var nome = document.getElementById("CBTri").value;
		if(nome == ""){ alert("CBTri não preenchido."); document.getElementById("CBTri").focus(); return false; }
	}*/
	/*if (document.getElementById("FGTri")){ 
		var nome = document.getElementById("FGTri").value;
		if(nome == ""){ alert("FGTri não preenchido."); document.getElementById("FGTri").focus(); return false; }
	}*/
	if (document.getElementById("FederarRenovar")){ 
		var nome = document.getElementById("FederarRenovar").value;
		if(nome == ""){ alert("Federação/Renovação não selecionada."); document.getElementById("FederarRenovar").focus(); return false; }
	}
	if (document.getElementById("Nome")){ 
		var nome = document.getElementById("Nome").value;
		if(nome == ""){ alert("Nome não preenchido."); document.getElementById("Nome").focus(); return false; }
	}
	if (document.getElementById("Sexo")){ 
		var nome = document.getElementById("Sexo").value;
		if(nome == ""){ alert("Sexo não selecionado."); document.getElementById("Sexo").focus(); return false; }
	}
	if (document.getElementById("DataNascimento")){ 
		var DataNascimento = document.getElementById("DataNascimento").value;
		if(DataNascimento.length < 10 || DataNascimento.length > 10){ 
			alert("Data de Nascimento incorreta ou não preenchida."); document.getElementById("DataNascimento").focus(); return false;
		}
		else {
			
			data = new Date(); 
			dia = data.getDate(); 
			mes = parseInt(data.getMonth()) + 1; 
			ano = data.getFullYear();
			
			vldResponsavel 	= 0; 
			dataCadastro 	= DataNascimento.split("/");
			idade 			= parseInt(ano) - parseInt(dataCadastro[2]);
			
			if(idade < 18){
				vldResponsavel = 1;
			}
			else{
				if(idade == 18){
					if(mes < dataCadastro[1]){
						vldResponsavel = 1;
					}
					else{
						if(mes == dataCadastro[1]){
							if(dia < dataCadastro[0]){
								vldResponsavel = 1;
							}
						}
					}
				}
			}
		}
	}
	if (document.getElementById("Email")){ 
		var email = document.getElementById("Email").value; 
		if(email == "" || email.match(/(\w+)@(.+)\.(\w+)$/) == null){ 
		alert("Email incorreto ou não preenchido."); document.getElementById("Email").focus(); return false; }
	}
	if (document.getElementById("Endereco")){ 
		var endereco = document.getElementById("Endereco").value; 
		if(endereco == ""){ alert("Endereço não preenchido."); document.getElementById("Endereco").focus(); return false; }
	}
	if (document.getElementById("Cidade")){ 
		var cidade = document.getElementById("Cidade").value;
		if(cidade == ""){ alert("Cidade não preenchida."); document.getElementById("Cidade").focus(); return false; }
	}
	if (document.getElementById("UF")){ 
		var estado = document.getElementById("UF").value; 
		if(estado == ""){ alert("UF não selecionada."); document.getElementById("UF").focus(); return false; }
	}
	if (document.getElementById("CEP")){
		var cep = document.getElementById("CEP").value;
		if(cep.length != 9){ 
		alert("CEP incorreto ou não preenchido."); document.getElementById("CEP").focus(); return false; }
	}
	if (document.getElementById("Telefone")){ 
		var telRes = document.getElementById("Telefone").value;
		if(telRes.length < 14 || telRes.length > 14){ 
		alert("Telefone incorreto ou não preenchido."); document.getElementById("Telefone").focus(); return false; }
	}
	if (document.getElementById("Celular")){ 
		var telCel = document.getElementById("Celular").value;
		if(telCel.length < 14 || telCel.length > 14){ 
		alert("Celular incorreto ou não preenchido."); document.getElementById("Celular").focus(); return false; }
	}
	if (document.getElementById("RG")){
		var rg = document.getElementById("RG").value;
		if(rg.length != 10){ alert("RG incorreto ou não preenchido."); document.getElementById("RG").focus(); return false; }
	}
	if (document.getElementById("CPF")){
		var cpf = document.getElementById("CPF").value;
		if(cpf.length != 14){ alert("CPF incorreto ou não preenchido."); document.getElementById("CPF").focus(); return false; }
	}
	if (document.getElementById("Altura")){
		var Altura = document.getElementById("Altura").value;
		if(Altura.length != 4){ alert("Altura incorreta ou não preenchida."); document.getElementById("Altura").focus(); return false; }
	}
	if (document.getElementById("Peso")){
		var Peso = document.getElementById("Peso").value;
		if(Peso.length < 6 || Peso.length > 7){ alert("Peso incorreto ou não preenchido."); document.getElementById("Peso").focus(); return false; }
	}
	if (document.getElementById("NumCamiseta")){
		var NumCamiseta = document.getElementById("NumCamiseta").value;
		if(NumCamiseta == ""){ alert("Nº da Camiseta não selecionado."); document.getElementById("NumCamiseta").focus(); return false; }
	}
	if (document.getElementById("NumCalcado")){
		var NumCalcado = document.getElementById("NumCalcado").value;
		if(NumCalcado.length != 2){ alert("Nº do Calçado incorreto ou não preenchido."); document.getElementById("NumCalcado").focus(); return false; }
	}
	
	var modalidade = document.getElementById("Modalidade").value;
	if(modalidade == ""){ alert("Modalidade não selecionada."); document.getElementById("Modalidade").focus(); return false; }
	
	if (document.getElementById("NomePai")){
		var NomePai = document.getElementById("NomePai").value;
		if(NomePai == ""){ alert("Nome do Pai não preenchido."); document.getElementById("NomePai").focus(); return false; }
	}
	if (document.getElementById("NomeMae")){
		var NomeMae = document.getElementById("NomeMae").value;
		if(NomeMae == ""){ alert("Nome da Mãe não preenchido."); document.getElementById("NomeMae").focus(); return false; }
	}
	if (document.getElementById("Equipe")){
		var Equipe = document.getElementById("Equipe").value;
		if(Equipe == ""){ alert("Equipe não preenchida."); document.getElementById("Equipe").focus(); return false; }
	}
	if(vldResponsavel == 1){
		if (document.getElementById("Responsavel")){
			var Responsavel = document.getElementById("Responsavel").value;
			if(Responsavel == ""){ alert("Responsável não preenchido."); document.getElementById("Responsavel").focus(); return false; }
		}
	}
	
	
	var FormaPagamento 	= document.getElementById("FormaPagamento").value;
	
	switch(FormaPagamento){
	case "fp1":
	  
		var especie			= document.getElementById("especie").value;
	 	var valor_deposito	= document.getElementById("valor_deposito").value;
	 	var data_deposito	= document.getElementById("data_deposito").value;
	 	var numero_terminal	= document.getElementById("numero_terminal").value;
	 	var numero_agencia	= document.getElementById("numero_agencia").value;
		
		if(valor_deposito == "" || valor_deposito <= 0){
			alert("Valor do Depósito Incorreto");
			document.getElementById("valor_deposito").focus();
			return false;
		}
		
		if(data_deposito == "" || data_deposito.length != 10){
			alert("Data do Depósito Incorreta");
			document.getElementById("data_deposito").focus();
			return false;
		}
		
		if(numero_terminal == ""){
			alert("Nº do Terminal não preenchido");
			document.getElementById("numero_terminal").focus();
			return false;
		}
		
		if(numero_agencia == ""){
			alert("Nº da Agência não preenchido");
			document.getElementById("numero_agencia").focus();
			return false;
		}
	  
	  break;
	case "fp2":
	
		var especie				= document.getElementById("especie").value;
	 	var valor_deposito		= document.getElementById("valor_deposito").value;
	 	var data_deposito		= document.getElementById("data_deposito").value;
	 	var horario_deposito	= document.getElementById("horario_deposito").value;
		
		if(valor_deposito == "" || valor_deposito <= 0){
			alert("Valor do Depósito Incorreto");
			document.getElementById("valor_deposito").focus();
			return false;
		}
		
		if(data_deposito == "" || data_deposito.length != 10){
			alert("Data do Depósito Incorreta");
			document.getElementById("data_deposito").focus();
			return false;
		}
		
		if(horario_deposito == "" || horario_deposito.length != 5){
			alert("Horário do Depósito Incorreto");
			document.getElementById("horario_deposito").focus();
			return false;
		}
	
	  break;
	case "fp3":
	
		var valor_transferencia		= document.getElementById("valor_transferencia").value;
	 	var data_transferencia		= document.getElementById("data_transferencia").value;
	 	var horario_transferencia	= document.getElementById("horario_transferencia").value;
	 	var codigo_transferencia	= document.getElementById("codigo_transferencia").value;
		
		if(valor_transferencia == "" || valor_transferencia <= 0){
			alert("Valor da Transferência Incorreto");
			document.getElementById("valor_transferencia").focus();
			return false;
		}
		
		if(data_transferencia == "" || data_transferencia.length != 10){
			alert("Data da Transferência Incorreta");
			document.getElementById("data_transferencia").focus();
			return false;
		}
		
		if(horario_transferencia == "" || horario_transferencia.length != 5){
			alert("Horário da Transferência Incorreto");
			document.getElementById("horario_transferencia").focus();
			return false;
		}
		
		if(codigo_transferencia == ""){
			alert("Código da transferência não preenchido");
			document.getElementById("codigo_transferencia").focus();
			return false;
		}
	
	  break;
	 case "fp4":
	
		var valor_transferencia		= document.getElementById("valor_transferencia").value;
	 	var data_transferencia		= document.getElementById("data_transferencia").value;
	 	var agencia_transferencia	= document.getElementById("agencia_transferencia").value;
	 	var terminal_transferencia	= document.getElementById("terminal_transferencia").value;
		
		if(valor_transferencia == "" || valor_transferencia <= 0){
			alert("Valor da Transferência Incorreto");
			document.getElementById("valor_transferencia").focus();
			return false;
		}
		
		if(data_transferencia == "" || data_transferencia.length != 10){
			alert("Data da Transferência Incorreta");
			document.getElementById("data_transferencia").focus();
			return false;
		}
		
		if(agencia_transferencia == ""){
			alert("Nº da Agência Bancária não preenchido");
			document.getElementById("agencia_transferencia").focus();
			return false;
		}
		
		if(terminal_transferencia == ""){
			alert("Nº do Terminal não preenchido");
			document.getElementById("terminal_transferencia").focus();
			return false;
		}
	
	  break;
	 case "fp5":
	
		var valor_transferencia		= document.getElementById("valor_transferencia").value;
	 	var data_transferencia		= document.getElementById("data_transferencia").value;
	 	var banco_transferencia		= document.getElementById("banco_transferencia").value;
	 	var agencia_transferencia	= document.getElementById("agencia_transferencia").value;
	 	var terminal_transferencia	= document.getElementById("terminal_transferencia").value;
		
		if(valor_transferencia == "" || valor_transferencia <= 0){
			alert("Valor da Transferência Incorreto");
			document.getElementById("valor_transferencia").focus();
			return false;
		}
		
		if(data_transferencia == "" || data_transferencia.length != 10){
			alert("Data da Transferência Incorreta");
			document.getElementById("data_transferencia").focus();
			return false;
		}
		
		if(banco_transferencia == ""){
			alert("Nome do Banco não preenchido");
			document.getElementById("banco_transferencia").focus();
			return false;
		}
		
		if(agencia_transferencia == ""){
			alert("Nº da Agência Bancária não preenchido");
			document.getElementById("agencia_transferencia").focus();
			return false;
		}
		
		if(terminal_transferencia == ""){
			alert("Nº do Terminal não preenchido");
			document.getElementById("terminal_transferencia").focus();
			return false;
		}
	
	  break;
	 default:
	 	alert("Selecione a Forma de Pagamento");
		return false;
	}
	
		
	xmlHttp=GetXmlHttpObject();
	url="captchacode.asp";
	
	var captchacode = document.getElementById("captchacode").value;
	
	url = url + "?sid=" + Math.random();
	url = url + "&captchacode="+ captchacode;
	
	xmlHttp.onreadystatechange = VerificaCaptchacode;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	function VerificaCaptchacode(){ 
		
		if (xmlHttp.readyState == 4) { 
		
			if(xmlHttp.responseText==0){
				alert("Código de segurança inválido ou não preenchido");
			}else{
				document.getElementById("span").value = "validado";
				document.formFaleConsoco.submit();
			}
		}
	}
}

function validaFormIncluirFilial(){
	
	var nome 			= document.getElementById("Nome").value;
	var site			= document.getElementById("Site").value;
	var telefone 		= document.getElementById("Telefone").value;
	var telefone2		= document.getElementById("Telefone2").value;
	var email 			= document.getElementById("Email").value;
	var email2 			= document.getElementById("Email2").value;
	var ativComercial	= document.getElementById("AtividadeComercial").value;
	var cnpj	 		= document.getElementById("Cnpj").value;
	var inscEstadual 	= document.getElementById("InscricaoEstadual").value;
	var inscMunicipal	= document.getElementById("InscricaoMunicipal").value;
	var razaoSocial		= document.getElementById("RazaoSocial").value;
	var nomeFantasia	= document.getElementById("NomeFantasia").value;
	var endereco 		= document.getElementById("Endereco").value;
	var numero	 		= document.getElementById("Numero").value;
	var complemento		= document.getElementById("Complemento").value;
	var cep		 		= document.getElementById("Cep").value;
	var estado	 		= document.getElementById("Estado").value;
	var cidade	 		= document.getElementById("Cidade").value;
	var bairro	 		= document.getElementById("Bairro").value;
	var login			= document.getElementById("Login").value;
	var senha			= document.getElementById("Senha").value;
	var senha2			= document.getElementById("Senha2").value;
			
	if (nome == ""){
		alert("Nome não preenchido");
		document.getElementById("Nome").focus();
		return false;
	}
	if (telefone.length < 14 || telefone.length > 14){
		alert("Telefone incorreto ou não preenchido");
		document.getElementById("Telefone").focus();
		return false;
	}
	if (telefone2.length < 14 || telefone2.length > 14){
		if (telefone2 != ""){
			alert("Telefone2 incorreto");
			document.getElementById("Telefone2").focus();
			return false;
		}
	}
	if (email == "" || email.match(/(\w+)@(.+)\.(\w+)$/) == null){
		alert("Email incorreto ou não preenchido");
		document.getElementById("Email").focus();
		return false;
	}
	if (email2 != "" && email2.match(/(\w+)@(.+)\.(\w+)$/) == null){
		alert("Email incorreto ou não preenchido");
		document.getElementById("Email2").focus();
		return false;
	}
	if (cnpj.length < 18 || cnpj.length > 18){
		alert("Cnpj incorreto ou não preenchido");
		document.getElementById("Cnpj").focus();
		return false;
	}
	if (inscEstadual.length < 10 && inscEstadual != ""){
		alert("Inscrição Estadual incorreta ou não preenchida");
		document.getElementById("InscricaoEstadual").focus();
		return false;
	}
	if (inscMunicipal.length < 10 && inscMunicipal != ""){
		alert("Inscrição Municipal incorreta");
		document.getElementById("InscricaoMunicipal").focus();
		return false;
	}
	if (razaoSocial == ""){
		alert("Razão Social não preenchida");
		document.getElementById("RazaoSocial").focus();
		return false;
	}
	if (nomeFantasia == ""){
		alert("Nome Fantasia não preenchido");
		document.getElementById("NomeFantasia").focus();
		return false;
	}
	if (endereco == ""){
		alert("Endereço não preenchido");
		document.getElementById("Endereco").focus();
		return false;
	}
	if (numero == ""){
		alert("Número não preenchido");
		document.getElementById("Numero").focus();
		return false;
	}
	if (estado == ""){
		alert("Estado não selecionado");
		document.getElementById("Estado").focus();
		return false;
	}
	if (cidade == ""){
		alert("Cidade não selecionada");
		document.getElementById("Cidade").focus();
		return false;
	}
	if (bairro == ""){
		alert("Bairro não selecionado");
		document.getElementById("Bairro").focus();
		return false;
	}
	if (login == ""){
		alert("Login não preenchido");
		document.getElementById("Login").focus();
		return false;
	}
	if (senha == "" || senha2 == ""){
		alert("Senha não preenchida");
		document.getElementById("Senha").focus();
		return false;
	}
	else{
		if(senha != senha2){
			alert("As senhas não conferem");
			document.getElementById("Senha").focus();
			return false;
		}
	}
	
	document.incluirFilial.submit();
}

function validaFormIncluirAgenda(){
	
	var titulo 			= document.getElementById("Titulo").value;
	var mensagem		= CKEDITOR.instances.mensagem.getData();
	var dataInicio		= document.getElementById("Data_Inicio").value;
	var dataTermino		= document.getElementById("Data_Termino").value;
	var horaInicio		= document.getElementById("Hora_Inicio").value;
	var horaTermino		= document.getElementById("Hora_Termino").value;
	var email	 		= document.getElementById("Email").value;
	var telefone		= document.getElementById("Telefone").value;
	var cidade	 		= document.getElementById("Cidade").value;
	var endereco 		= document.getElementById("Endereco").value;
	
	if (titulo == ""){
		alert("Nome do Evento não preenchido");
		document.getElementById("Titulo").focus();
		return false;
	}
	if(mensagem == ""){
		alert("Mensagem não preenchida");
		document.getElementById("Mensagem").focus();
		return false;
	}
	if(dataInicio == "" || dataInicio.length < 10){
		alert("Data de Início do Evento não preenchida ou incorreta");
		document.getElementById("Data_Inicio").focus();
		return false;
	}
	if(dataTermino != "" && dataTermino.length < 10){
		alert("Data de Término do Evento incorreta");
		document.getElementById("Data_Termino").focus();
		return false;
	}
	if(horaInicio != "" && horaInicio.length < 5){
		alert("Horário de Início do Evento incorreto");
		document.getElementById("Hora_Inicio").focus();
		return false;
	}
	if(horaTermino != "" && horaTermino.length < 5){
		alert("Horário de Término do Evento incorreto");
		document.getElementById("Hora_Termino").focus();
		return false;
	}
	if (email != "" && email.match(/(\w+)@(.+)\.(\w+)$/) == null){
		alert("Email incorreto");
		document.getElementById("Email").focus();
		return false;
	}
	if (telefone != "" && telefone.length < 14){
		alert("Telefone incorreto");
		document.getElementById("Telefone").focus();
		return false;
	}
	if (cidade == ""){
		alert("Cidade não selecionada");
		document.getElementById("Cidade").focus();
		return false;
	}
	if (endereco == ""){
		alert("Endereço não preenchido");
		document.getElementById("Endereco").focus();
		return false;
	}
	
	document.incluirAgenda.submit();
	
}

function validarModuloNoticias(){
	
	var Titulo 			= document.getElementById("Titulo").value;
	var DataCadastro 	= document.getElementById("DataCadastro").value;
	var Texto 			= CKEDITOR.instances.Texto.getData();
	
	if(Titulo == ""){
		alert("Título não preenchido");
		document.getElementById("Titulo").focus();
		return false;
	}
	if(Texto == ""){
		alert("Texto não preenchido");
		document.getElementById("Texto").focus();
		return false;
	}
	if(DataCadastro == "" || DataCadastro.length < 10){
		alert("Data não preenchida ou incorreta");
		document.getElementById("DataCadastro").focus();
		return false;
	}
	
	document.incluirNoticia.submit();
}

function validaFormIncluirUsuario(){
	
	var login 	= document.getElementById("Login").value;
	var senha 	= document.getElementById("Senha").value;
	var senha2	= document.getElementById("Senha2").value;
	
	if(login == ""){
		alert("Usuário não preenchido");
		document.getElementById("Login").focus();
		return false;
	}
	if (senha == "" || senha2 == ""){
		alert("Senha não preenchida");
		document.getElementById("Senha").focus();
		return false;
	}
	else{
		if(senha != senha2){
			alert("As senhas não conferem");
			document.getElementById("Senha").focus();
			return false;
		}
	}
	
	document.incluirUsuario.submit();
}

function validaFormIncluirLink(){
	
	var categoria 	= document.getElementById("id_Categoria").value;
	var nome		= document.getElementById("Nome").value;
	var site		= document.getElementById("Site").value;
	
	if(categoria == ""){
		alert("Categoria não selecionada");
		document.getElementById("id_Categoria").focus();
		return false;
	}
	if(nome == ""){
		alert("Nome não preenchido");
		document.getElementById("Nome").focus();
		return false;
	}
	if(site == ""){
		alert("Site não preenchido");
		document.getElementById("Site").focus();
		return false;
	}
	
	document.incluirLink.submit();
}

function validaFormIncluirFotoFilial(){
	var imagem = document.getElementById("Imagem").value;
	
	if(imagem == ""){
		alert("Imagem não preenchida");
		document.getElementById("Imagem").focus();
		return false;
	}
	
	document.incluirFotoFilial.submit();
}

function validaFormIncluirCategoria(){
	var nome = document.getElementById("Nome").value;
	
	if(nome == ""){
		alert("Nome não preenchido");
		document.getElementById("Nome").focus();
		return false;
	}
	
	document.incluirCategoria.submit();
}

function validaFormIncluirParceiro(){
	
	var nome 		= document.getElementById("Nome").value;
	var telefone 	= document.getElementById("Telefone").value;
	var categoria 	= document.getElementById("Categoria").value;
	
	if(nome == ""){
		alert("Nome não preenchido");
		document.getElementById("Nome").focus();
		return false;
	}
	if (telefone.length < 14 || telefone.length > 14){
		if (telefone != ""){
			alert("Telefone incorreto");
			document.getElementById("Telefone").focus();
			return false;
		}
	}
	
	document.incluirParceiro.submit();
}

function validaFormInscricao(){

	var FormaPagamento = document.getElementById("forma_pagamento").value;
	
	switch(FormaPagamento){
	case "fp1":
	  
		var especie			= document.getElementById("especie").value;
	 	var valor_deposito	= document.getElementById("valor_deposito").value;
	 	var data_deposito	= document.getElementById("data_deposito").value;
	 	var numero_terminal	= document.getElementById("numero_terminal").value;
	 	var numero_agencia	= document.getElementById("numero_agencia").value;
		
		if(valor_deposito == "" || valor_deposito <= 0){
			alert("Valor do Depósito Incorreto");
			document.getElementById("valor_deposito").focus();
			return false;
		}
		
		if(data_deposito == "" || data_deposito.length != 10){
			alert("Data do Depósito Incorreta");
			document.getElementById("data_deposito").focus();
			return false;
		}
		
		if(numero_terminal == ""){
			alert("Nº do Terminal não preenchido");
			document.getElementById("numero_terminal").focus();
			return false;
		}
		
		if(numero_agencia == ""){
			alert("Nº da Agência não preenchido");
			document.getElementById("numero_agencia").focus();
			return false;
		}
	  
	  break;
	case "fp2":
	
		var especie				= document.getElementById("especie").value;
	 	var valor_deposito		= document.getElementById("valor_deposito").value;
	 	var data_deposito		= document.getElementById("data_deposito").value;
	 	var horario_deposito	= document.getElementById("horario_deposito").value;
		
		if(valor_deposito == "" || valor_deposito <= 0){
			alert("Valor do Depósito Incorreto");
			document.getElementById("valor_deposito").focus();
			return false;
		}
		
		if(data_deposito == "" || data_deposito.length != 10){
			alert("Data do Depósito Incorreta");
			document.getElementById("data_deposito").focus();
			return false;
		}
		
		if(horario_deposito == "" || horario_deposito.length != 5){
			alert("Horário do Depósito Incorreto");
			document.getElementById("horario_deposito").focus();
			return false;
		}
	
	  break;
	case "fp3":
	
		var valor_transferencia		= document.getElementById("valor_transferencia").value;
	 	var data_transferencia		= document.getElementById("data_transferencia").value;
	 	var horario_transferencia	= document.getElementById("horario_transferencia").value;
	 	var codigo_transferencia	= document.getElementById("codigo_transferencia").value;
		
		if(valor_transferencia == "" || valor_transferencia <= 0){
			alert("Valor da Transferência Incorreto");
			document.getElementById("valor_transferencia").focus();
			return false;
		}
		
		if(data_transferencia == "" || data_transferencia.length != 10){
			alert("Data da Transferência Incorreta");
			document.getElementById("data_transferencia").focus();
			return false;
		}
		
		if(horario_transferencia == "" || horario_transferencia.length != 5){
			alert("Horário da Transferência Incorreto");
			document.getElementById("horario_transferencia").focus();
			return false;
		}
		
		if(codigo_transferencia == ""){
			alert("Código da transferência não preenchido");
			document.getElementById("codigo_transferencia").focus();
			return false;
		}
	
	  break;
	 case "fp4":
	
		var valor_transferencia		= document.getElementById("valor_transferencia").value;
	 	var data_transferencia		= document.getElementById("data_transferencia").value;
	 	var agencia_transferencia	= document.getElementById("agencia_transferencia").value;
	 	var terminal_transferencia	= document.getElementById("terminal_transferencia").value;
		
		if(valor_transferencia == "" || valor_transferencia <= 0){
			alert("Valor da Transferência Incorreto");
			document.getElementById("valor_transferencia").focus();
			return false;
		}
		
		if(data_transferencia == "" || data_transferencia.length != 10){
			alert("Data da Transferência Incorreta");
			document.getElementById("data_transferencia").focus();
			return false;
		}
		
		if(agencia_transferencia == ""){
			alert("Nº da Agência Bancária não preenchido");
			document.getElementById("agencia_transferencia").focus();
			return false;
		}
		
		if(terminal_transferencia == ""){
			alert("Nº do Terminal não preenchido");
			document.getElementById("terminal_transferencia").focus();
			return false;
		}
	
	  break;
	 case "fp5":
	
		var valor_transferencia		= document.getElementById("valor_transferencia").value;
	 	var data_transferencia		= document.getElementById("data_transferencia").value;
	 	var banco_transferencia		= document.getElementById("banco_transferencia").value;
	 	var agencia_transferencia	= document.getElementById("agencia_transferencia").value;
	 	var terminal_transferencia	= document.getElementById("terminal_transferencia").value;
		
		if(valor_transferencia == "" || valor_transferencia <= 0){
			alert("Valor da Transferência Incorreto");
			document.getElementById("valor_transferencia").focus();
			return false;
		}
		
		if(data_transferencia == "" || data_transferencia.length != 10){
			alert("Data da Transferência Incorreta");
			document.getElementById("data_transferencia").focus();
			return false;
		}
		
		if(banco_transferencia == ""){
			alert("Nome do Banco não preenchido");
			document.getElementById("banco_transferencia").focus();
			return false;
		}
		
		if(agencia_transferencia == ""){
			alert("Nº da Agência Bancária não preenchido");
			document.getElementById("agencia_transferencia").focus();
			return false;
		}
		
		if(terminal_transferencia == ""){
			alert("Nº do Terminal não preenchido");
			document.getElementById("terminal_transferencia").focus();
			return false;
		}
	
	  break;
	 default:
	 	alert("Selecione a Forma de Pagamento");
		return false;
	}
	
	if(document.getElementsByName("Nome")){
		
		var Nome = document.getElementById("Nome").value;
		
		if(Nome == ""){
			alert("Nome não preenchido");
			document.getElementById("Nome").focus();
			return false;
		}
		
	}
	if(document.getElementsByName("Sexo")){
		
		var Sexo = document.getElementById("Sexo").value;
		
		if(Sexo == ""){
			alert("Sexo não preenchido");
			document.getElementById("Sexo").focus();
			return false;
		}
	
	}
	if(document.getElementsByName("Data_Nascimento")){
		
		var Data_Nasc = document.getElementById("Data_Nascimento").value;
		
		if(Data_Nasc == "" || Data_Nasc.length != 10){
			alert("Data de Nascimento incorreta");
			document.getElementById("Data_Nascimento").focus();
			return false;
		}
	}
	if(document.getElementsByName("CPF")){
		
		var CPF = document.getElementById("CPF").value;
		
		if(CPF == "" || CPF.length != 14){
			alert("CPF incorreto");
			document.getElementById("CPF").focus();
			return false;
		}
	}
	if(document.getElementsByName("RG")){
		
		var RG = document.getElementById("RG").value;
		
		if(RG == "" || RG.length != 10){
			alert("RG incorreto");
			document.getElementById("RG").focus();
			return false;
		}
	}
	if(document.getElementsByName("Endereco")){
		
		var Endereco = document.getElementById("Endereco").value;
		
		if(Endereco == ""){
			alert("Endereço não preenchido");
			document.getElementById("Categoria").focus();
			return false;
		}
	}
	if(document.getElementsByName("Numero")){
		
		var Numero = document.getElementById("Numero").value;
		
		if(Numero == ""){
			alert("Número não preenchido");
			document.getElementById("Categoria").focus();
			return false;
		}
	}
	if(document.getElementsByName("Cidade")){
		
		var Cidade = document.getElementById("Cidade").value;
		
		if(Cidade == ""){
			alert("Cidade não preenchida");
			document.getElementById("Cidade").focus();
			return false;
		}
	}
	if(document.getElementsByName("UF")){
		
		var UF = document.getElementById("UF").value;
		
		if(UF == ""){
			alert("UF não preenchida");
			document.getElementById("UF").focus();
			return false;
		}
	}
	if(document.getElementsByName("CEP")){
		
		var CEP = document.getElementById("CEP").value;
		
		if(CEP == "" || CEP.length != 9){
			alert("CEP incorreto");
			document.getElementById("CEP").focus();
			return false;
		}
	}
	if(document.getElementsByName("Telefone")){
		
		var Telefone = document.getElementById("Telefone").value;
		
		if(Telefone == "" || Telefone.length != 14){
			alert("Telefone incorreto");
			document.getElementById("Telefone").focus();
			return false;
		}
	}
	if(document.getElementsByName("Email")){
		
		var Email = document.getElementById("Email").value;
		
		if(Email == "" || Email.match(/(\w+)@(.+)\.(\w+)$/) == null){
			alert("E-mail não preenchido");
			document.getElementById("Email").focus();
			return false;
		}
	}
	
	var termo_compromisso = document.getElementById("termoCompromisso").checked;
	
	if(!termo_compromisso){
		alert("Para prosseguir é necessário aceitar os termos de compromisso do Evento.");
	}
		
	xmlHttp=GetXmlHttpObject();
	url = "captchacode.asp";
	
	var captchacode = document.getElementById("captchacode").value;
	
	url = url + "?sid=" + Math.random();
	url = url + "&captchacode="+ captchacode;
	
	xmlHttp.onreadystatechange = VerificaCaptchacode;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	function VerificaCaptchacode(){ 
		
		if (xmlHttp.readyState == 4) { 
		
			if(xmlHttp.responseText==0){
				alert("Código de segurança inválido ou não preenchido");
			}else{
				document.getElementById("span").value = "validado";
				document.formInscricao.submit();
			}
		}
	}

}

function validaFormClassificado(){
	
	var nome 		= document.getElementById("Nome").value;
	var email 		= document.getElementById("Email").value;
	var telefone 	= document.getElementById("Telefone").value;
	var cidade 		= document.getElementById("Cidade").value;
	var uf 			= document.getElementById("UF").value;
	var titulo 		= document.getElementById("Titulo").value;
	var descricao 	= document.getElementById("Descricao").value;
	var categoria	= document.getElementById("Categoria").value;
	var preco 		= document.getElementById("Preco").value;
	var captchacode = document.getElementById("captchacode").value;
	
	if (nome == ""){ 
		alert("Nome não preenchido.");
		document.getElementById("Nome").focus();
		return false;
	}
	if (email == "" || email.match(/(\w+)@(.+)\.(\w+)$/) == null){ 
		alert("Email incorreto ou não preenchido.");
		document.getElementById("Email").focus();
		return false;
	}
	if (telefone == "" || telefone.length != 14){ 
		alert("Telefone incorreto ou não preenchido.");
		document.getElementById("Telefone").focus();
		return false;
	}
	if (cidade == ""){ 
		alert("Cidade não preenchida.");
		document.getElementById("Cidade").focus();
		return false;
	}
	if (uf == ""){ 
		alert("UF não selecionada.");
		document.getElementById("UF").focus();
		return false;
	}
	if (titulo == ""){ 
		alert("Titulo não preenchido.");
		document.getElementById("Titulo").focus();
		return false;
	}
	if (descricao == ""){ 
		alert("Descrição não preenchida.");
		document.getElementById("Descricao").focus();
		return false;
	}
	if (categoria == ""){ 
		alert("Categoria não selecionada.");
		document.getElementById("Categoria").focus();
		return false;
	}
	if(document.getElementsByName("Subcategoria")){
		
		var subcategoria = document.getElementById("Subcategoria").value;
		if(subcategoria == ""){
			alert("Subcategoria não selecionada.");
			document.getElementById("Subcategoria").focus();
			return false;
		}
		
	}
	if (preco == ""){ 
		alert("Preço não preenchido.");
		document.getElementById("Preco").focus();
		return false;
	}
		
	xmlHttp=GetXmlHttpObject();
	url="captchacode.asp";
	
	url = url + "?sid=" + Math.random();
	url = url + "&captchacode="+ captchacode;
	
	xmlHttp.onreadystatechange = VerificaCaptchacode;
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	function VerificaCaptchacode(){ 
		
		if (xmlHttp.readyState == 4) { 
		
			if(xmlHttp.responseText==0){
				alert("Código de segurança inválido ou não preenchido");
			}else{
				document.getElementById("span").value = "validado";
				document.incluirClassificado.submit();
			}
		}
	}
}

function validaFormContatoAssociado(){
	
	var nome 		= document.getElementById("Nome").value;
	var email 		= document.getElementById("Email").value;
	var mensagem 	= document.getElementById("Mensagem").value;
	var contato		= document.getElementById("Contato").value;
	
	if(nome == ""){
		alert("Nome não preenchido");
		document.getElementById("Nome").focus();
		return false;
	}
	if (email.match(/(\w+)@(.+)\.(\w+)$/) == null){
		alert("Email incorreto ou não preenchido");
		document.getElementById("Email").focus();
		return false;
	}
	if(mensagem == ""){
		alert("Mensagem não preenchida");
		document.getElementById("Mensagem").focus();
		return false;
	}
	if(contato != ""){
		return false;
	}
	
	document.frmContatoAssociado.submit();
}

function val_login(){
	
	var login = document.getElementById("email").value;
	var senha = document.getElementById("senha").value;
	
	if (login.match(/(\w+)@(.+)\.(\w+)$/) == null){
		alert("Email incorreto ou não preenchido");
		document.getElementById("email").focus();
		return false;
	}
	
	if (senha == ""){
		alert("Senha não preenchida");
		document.getElementById("senha").focus();
		return false;
	}
	
	document.frm_continuar_login.submit();
}

function valida_form_cadastro(){
	
	var nome 		= document.getElementById("nome").value;
	var email 		= document.getElementById("email").value;
	var email2 		= document.getElementById("email2").value;
	var telefone	= document.getElementById("telefone").value;
	var telefone2	= document.getElementById("telefone2").value;
	var data_nasc	= document.getElementById("data_nascimento").value;
	var rg		 	= document.getElementById("rg").value;
	var cpf			= document.getElementById("cpf").value;
	var logradouro 	= document.getElementById("logradouro").value;
	var numero		= document.getElementById("numero").value;
	var bairro		= document.getElementById("bairro").value;
	var cidade		= document.getElementById("cidade").value;
	var uf			= document.getElementById("UF").value;
	var cep			= document.getElementById("cep").value;
	var senha		= document.getElementById("senha").value;
	var valida_cpf	= 0;
	
	if(nome == ""){
		alert("Nome não preenchido");
		document.getElementById("nome").focus();
		return false;
	}
	if (email.match(/(\w+)@(.+)\.(\w+)$/) == null){
		alert("Email incorreto ou não preenchido");
		document.getElementById("email").focus();
		return false;
	}
	if (email2 != "" && email2.match(/(\w+)@(.+)\.(\w+)$/) == null){
		alert("Email Alternativo incorreto");
		document.getElementById("email2").focus();
		return false;
	}
	if (telefone.length != 14){
		alert("Telefone incorreto ou não preenchido");
		document.getElementById("telefone").focus();
		return false;
	}
	if (telefone2 != "" && telefone2.length != 14){
		alert("Celular incorreto");
		document.getElementById("email2").focus();
		return false;
	}
	if(data_nasc.length != 10){
		alert("Data de Nascimento incorreta");
		document.getElementById("data_nascimento").focus();
		return false;
	}
	if(rg.length != 10){
		alert("RG incorreta");
		document.getElementById("rg").focus();
		return false;
	}
	if(cpf.length != 14){
		alert("CPF inválido");
		document.getElementById("cpf").focus();
		return false;
	}
	if(logradouro == ""){
		alert("Logradouro não preenchido");
		document.getElementById("logradouro").focus();
		return false;
	}
	if(numero == ""){
		alert("Número não preenchido");
		document.getElementById("numero").focus();
		return false;
	}
	if(bairro == ""){
		alert("Bairro não preenchido");
		document.getElementById("bairro").focus();
		return false;
	}
	if(cidade == ""){
		alert("Cidade não preenchida");
		document.getElementById("cidade").focus();
		return false;
	}
	if(uf == ""){
		alert("UF incorreta");
		document.getElementById("UF").focus();
		return false;
	}
	if(cep.length != 9){
		alert("CEP incorreto");
		document.getElementById("cep").focus();
		return false;
	}
	if(senha == ""){
		alert("Senha não definida");
		document.getElementById("senha").focus();
		return false;
	}
	
	var xmlHttp 	= new GetXmlHttpObject();
	var url			= "ajax/valida_cpf.asp";
	
	url = url + "?sid=" + Math.random();
	url	= url + "&cpf="+ cpf;
	
	xmlHttp.onreadystatechange = mostra_result_cpf;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

	function mostra_result_cpf(){ 
		if (xmlHttp.readyState == 4) {
			
			function checar_result(){
				if(xmlHttp.responseText != "True"){ 
					alert("CPF Inválido");
					document.getElementById("cpf").focus();
					return false;
				}
				else{
					document.finalizar_cadastro.submit();
				}
			}
			
			setTimeout(checar_result, 100);
		}
	}
}

function GetXmlHttpObject(){
	
	if (window.XMLHttpRequest) { a=new XMLHttpRequest(); } /*Objeto nativo (FF/Safari/Opera7.6+)*/
	else {  
		try { a = new ActiveXObject("Msxml2.XMLHTTP");  /*activeX (IE5.5+/MSXML2+)*/ }	 
		catch(e) {  
			try { a = new ActiveXObject("Microsoft.XMLHTTP"); /*activeX (IE5+/MSXML1)*/ }	 
			catch(e) { /* O navegador não tem suporte */ a = false; }  
		}  
	}   
	return a;  
}
