function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function buscaCEP(){
	
	var cep = $("#cep").val();
	var result;
	
	$.post('buscacep.php', {cep:cep}, function(resp){
		
		result = resp.split('/');
		
		$("#endereco").val(result[0]);
		$("#bairro").val(result[1]);
		$("#cidade").val(result[2]);
		$("#uf").val(result[3]);
	});
}

$(function($){
	
	//$("#parceiros").load('parc.php');
	
	/****************************
	
	Mostrar Submenu e Login

	*****************************/
	
	$("#ok_inscricao").click(function(){
		var treinamento = $("#treinamento").val();
		var nome = $("#nome").val();
		var cep = $("#cep").val();
		var endereco = $("#endereco").val();
		var numero = $("#numero").val();
		var complemento = $("#complemento").val();
		var bairro = $("#bairro").val();
		var cidade = $("#cidade").val();
		var uf = $("#uf").val();
		var profissao = $("#profissao").val();
		var empresa = $("#empresa").val();
		var boleto_e = $("#rd_email").val();
		var boleto_a = $("#rd_endereco").val();
		
		if(treinamento == ""){ alert("Digite o nome de um treinamento"); $("#treinamento").focus(); return false; }
		if(nome == ""){ alert("Digite seu nome"); $("#nome").focus(); return false; }
		if(cep == ""){ alert("Digite seu CEP"); $("#cep").focus(); return false; }
		if(endereco == ""){ alert("Digite seu endereço"); $("#endereco").focus(); return false; }
		if(numero == ""){ alert("Digite o número do endereço"); $("#numero").focus(); return false; }
		if(bairro == ""){ alert("Digite o bairro"); $("#bairro").focus(); return false; }
		if(cidade == ""){ alert("Digite a cidade"); $("#cidade").focus(); return false; }
		if(uf == ""){ alert("Digite a UF"); $("#uf").focus(); return false; }
		if(profissao == ""){ alert("Digite a sua profissão"); $("#profissao").focus(); return false; }
		if(empresa == ""){ alert("Digite o nome de sua empresa"); $("#empresa").focus(); return false; }
		
		$("#formInscricao").submit();
	});

	
	
	/****************************
	
		Mostrar Submenu e Login
	
	*****************************/
	
	$('div#nav ul li').click(function() {
		$(this).find('ul:first').toggle();
	});
	
	$("#move_login").click(function(){
		$("#usu").val('');
		$("#snh").val('');
		$("#login").slideToggle(function(){
			$("#usu").focus();
		});
	})

/*	$('div#nav ul li').mouseleave(function() {
		$('div#nav ul li ul').hide();
	});

	$('div#nav ul li ul').mouseleave(function() {
		$('div#nav ul li ul').hide();
	});
*/
	
	/****************************
	
		Link para Cadastro
	
	*****************************/

	$("#ok_cadastrar").click(function(){
		window.location.href="index.php?cadastro";
	})
	
	/****************************
	
		Formulário de cadastro
	
	*****************************/


	$("#ok_cad").click(function(){
		var nome = $("#nome_c").val();
		var sobrenome = $("#sobrenome_c").val();
		var email = $("#email_c").val();
		var telefone = $("#telefone_c").val();
		var senha = $("#senha_c").val();
		var news = '';
		
		if($("#news_c").is(":checked")){
			news = 's';
		}else{
			news = 'n';
		}
		
		if(nome == ""){ alert("Nome é obrigatório"); $("#nome_c").focus(); return false; }
		if(email == ""){ alert("E-mail é obrigatório"); $("#email_c").focus(); return false; }
		if(senha == ""){ alert("Senha é obrigatória"); $("#senha_c").focus(); return false; }
		
		var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
		
		if(regmail.test(email)){
			testmail = true;
		}else{
			testmail = false;
		}
		
		if(testmail == false){ alert("O e-mail informado é inválido"); $("#email_c").focus(); return false; }
		
		if(sobrenome != ''){
			nome = nome+' '+sobrenome;
		}
		
		$.post('cadastro_ok.php',{nome:nome,email:email,telefone:telefone,senha:senha,news:news},function(resp){
			if(resp != false){
				alert(resp);
			}else{
				alert("Cadastro realizado com sucesso");
				window.location.href="index.php?depoimentos";
			}
		})
	})

	/****************************
	
		Formulário de login
	
	*****************************/


	$("#ok_entrar").click(function(){
		var email = $("#email_l").val();
		var senha = $("#senha_l").val();
		
		if(email == ""){ alert("E-mail é obrigatório"); $("#email_l").focus(); return false; }
		if(senha == ""){ alert("Senha é obrigatória"); $("#senha_l").focus(); return false; }
		
		var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
		
		if(regmail.test(email)){
			testmail = true;
		}else{
			testmail = false;
		}
		
		if(testmail == false){ alert("O e-mail informado é inválido"); $("#email_c").focus(); return false; }
		
		$.post('logar.php',{email:email,senha:senha},function(resp){
			if(resp != false){
				alert(resp);
			}else{
				window.location.reload();
			}
		})
	})

	/****************************
	
		Envio de Depoimento
	
	*****************************/


	$("#ok_depoimento").click(function(){
		var nome = $("#nome_d").val();
		var empresa = $("#empresa_d").val();
		var texto = $("#depoimento_d").val();
		
		if(nome == ""){ alert("Nome é obrigatório"); $("#nome_d").focus(); return false; }
		if(empresa == ""){ alert("Empresa é obrigatório"); $("#empresa_d").focus(); return false; }
		if(texto == ""){ alert("Texto é obrigatório"); $("#depoimento_d").focus(); return false; }
		
		$.post('depoimento_ok.php',{nome:nome,empresa:empresa,texto:texto},function(resp){
			if(resp != false){
				alert(resp);
			}else{
				alert("Depoimento enviado com sucesso.");
				$("#nome_d").val('');
				$("#empresa_d").val('');
				$("#depoimento_d").val('');
			}
		})
	})
	
	/****************************
	
		Cadastro de Newsletter
	
	*****************************/


	$("#ok_enviar").click(function(){
		var nome = $("#nome_n").val();
		var email = $("#email_n").val();
		
		if(email == ""){ alert("E-mail é obrigatório"); $("#email_n").focus(); return false; }
		if(nome == ""){ alert("Nome é obrigatório"); $("#nome_n").focus(); return false; }
		
		var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
		
		if(regmail.test(email)){
			testmail = true;
		}else{
			testmail = false;
		}
		
		if(testmail == false){ alert("O e-mail informado é inválido"); $("#email_n").focus(); return false; }
		
		$.post('cadnews.php',{nome:nome,email:email},function(resp){
			if(resp != false){
				alert(resp);
			}else{
				alert("Newsletter cadastrado com sucesso");
				$("#nome_n").val('');
				$("#email_n").val('');
			}
		})
	})
	
	/****************************
	
		Formulário de contato
	
	*****************************/
	
	$("#ok_contato").click(function(){
		var nome = $("#nome_co").val();
		var email = $("#email_co").val();
		var telefone = $("#telefone_co").val();
		var assunto = $("#assunto_co").val();
		var mensagem = $("#mensagem_co").val();
		
		if(email == ""){ alert("E-mail é obrigatório"); $("#email_co").focus(); return false; }
		if(nome == ""){ alert("Nome é obrigatório"); $("#nome_co").focus(); return false; }
		if(telefone == ""){ alert("Telefone é obrigatório"); $("#telefone_co").focus(); return false; }
		if(assunto == ""){ alert("Assunto é obrigatório"); $("#assunto_co").focus(); return false; }
		if(mensagem == ""){ alert("Mensagem é obrigatória"); $("#mensagem_co").focus(); return false; }
		
		$.post('contato_ok.php',{nome:nome,email:email,telefone:telefone,assunto:assunto,mensagem:mensagem},function(resp){
			if(resp != false){
				alert(resp);
			}else{
				alert("Mensagem enviada com sucesso.");
				$("#nome_co").val('');
				$("#email_co").val('');
				$("#telefone_co").val('');
				$("#assunto_co").val('');
				$("#mensagem_co").val('');
			}
		})
	})
})
