$(document).ready(function(){
	
	//Mascaras
	$(".ddd").mask("99");
	$(".telefone").mask("9999-9999");
	$("#cep").mask("99999-999");
	$(".cpf").mask("999.999.999-99");
	$(".cnpj").mask("99.999.999/9999-99");
	$(".data").mask("99/99/9999");
	
	$('.ddd').keyup(function(){
		var teste = $(this).val();
		teste = teste.replace("_", "");
		if (teste.length==2)
			$(this).next("input").focus();
	})
	
	$('#website').keyup(function(){
		var site = $(this).val();
		site = site.replace(/http:\/\//g,"");
		$(this).val("http://"+site);
	});
	
	//completa cep
	$("#cep").blur(function(){
		buscaDadosCEP($(this));
	});
	
	$("select[name^='info[id_']").each(function(int){
		$(this).change(function(){
			if($(this).val()=='Outros')
				$("input[name^='info[']").eq(int).removeClass('none');
			else 
				$("input[name^='info[']").eq(int).addClass('none');
		});
	});
	
	$("select[name^='lingua[id_']").each(function(int){
		
		$(this).change(function(){

			if($(this).val()=='Outras')
				$("input[name^='lingua[']").eq(int).removeClass('none');
			else 
				$("input[name^='lingua[']").eq(int).addClass('none');
		});
	});
	
	$("select[name^='formacao[ano_']").change(function(){
		if($(this).val()=='Formado')
			$("input[name='formacao[data_conclusao][]']").attr('title','*');
		else 
			$("input[name='formacao[data_conclusao][]']").removeAttr('title');
	});
	
	//ATIVAÇÃO styleForm
	$("form").styleForm();
	
	//CAMPOS TOPO DO SITE
	//campo pesquisa
	$('.forms_topo .arealogin_pesquisa #pesquisa').focus(function(){
		valor = $(this).val();
		
		if(valor=="Pesquisa")
			$(this).val("");
	});
	$('.forms_topo .arealogin_pesquisa #pesquisa').blur(function(){
		valor = $(this).val();
		
		if(valor=="")
			$(this).val("Pesquisa");
	});
	
	//AREA RESTRITA
	
	$('.forms_topo .arealogin_segura #email_cnpj').focus(function(){
		valor = $(this).val();
		
		if(valor=="E-mail ou CNPJ")
			$(this).val("");
	});
	$('.forms_topo .arealogin_segura #email_cnpj').blur(function(){
		valor = $(this).val();
		
		if(valor=="")
			$(this).val("E-mail ou CNPJ");
	});
	
	//campos senha
	$('.forms_topo .arealogin_segura #senha').focus(function(){
		valor = $(this).val();
		
		if(valor=="Senha")
			$(this).val("");
	});
	$('.forms_topo .arealogin_segura #senha').blur(function(){
		valor = $(this).val();
		
		if(valor=="")
			$(this).val("Senha");
	});
	$('.logout').click(function() {
		$('.form_login').load(root+"ajax/logout.php", function() {
			location.reload();
		});
	})
	
	//area_interesse
	
	$('#area_interesse input[type="checkbox"]').click(function(){
		
		if($('#area_interesse input:checked').length >= 3)			
			$("#area_interesse input:not(:checked)").attr("disabled", "disabled");
		else
			$("#area_interesse input:not(:checked)").removeAttr("disabled");
		
	});
	
	/*$('.form_login').load(root+"ajax/loadtopo.php", function() {
		//campos email / cnpj
		
	});	*/	
});
