$(document).ready(function() {
	
	// Hollover das imagens da galeria
	$('.galeria').hover(
	function() {
		$(this).children('img').css('border', '5px dashed #01458E');
	},
	function() {
		$(this).children('img').css('border', '5px solid #DFE6EE');
	});
	
	// Ativa a galeria prettyPhoto
	$("#galeria a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
	
	// Valida form de oportunidades
	$('#cx_guia form, #cx_guia_cont').submit(function() {
		var boolValid = false;
		$('#cx_guia form input:radio, #cx_guia_cont form input:radio').each(function() {
			if ( $(this).is(':checked') ) {
				boolValid = true;
			}
		});
		if (boolValid == false) {
			alert('Escolha uma das opções!');
			return false;	
		}
	});
	
	// Valida formulários
	 $("#associe_form").validate({		
		rules: {
			senha: {
				required: true,
		  		minlength: 6
			},
			confirma_senha: {
				required: true,
		  		minlength: 6
			},
			confirma_senha: "required",
			confirma_senha: {
				equalTo: "#senha"
			},
			curriculo: {
				required: true,
		  		maxlength: 500
			}
	  	}
	});
	 
	 $("#login_form").validate({		
		
	});
	 
	 $("#contato_form").validate({		
		
	});
	 
	$("#vagas_form").validate({		
		rules: {
			senha: {
				required: true,
		  		minlength: 6
			},			
	  	}
	});
	
	// Verifica para mostrar o textarea de curriculo
	$('.form_curriculos').hide();
	$('.form_vagas').hide();
	$('#tipo').change(function() {
		if ($(this).val() == 'vagas') {			
			$('.form_curriculos').slideUp('slow');
			$('.form_vagas').slideDown('slow');
			$('.form_curriculos').removeClass('required');
		}
		else if ($(this).val() == 'Currículos') {
			$('.form_vagas').slideUp('slow');
			$('.form_curriculos').slideDown('slow');
			$('.form_vagas').removeClass('required');
		}
		else if ($(this).val() == '') {
			$('.form_vagas').slideUp('slow');
			$('.form_curriculos').slideUp('slow');
		}
	});	 
	 
	// Verifica buscar associados
	$('#bnome').click(function() {
		$('#select_associado').hide();
		$('#input_associado').show().focus();
								 
	});
	
	$('#bsegmento').click(function() {
		$('#input_associado').hide();
		$('#select_associado').show();										 
	});
	
	// Mostra busca
	$('.busca_det').hide();
	$('.busca_res').click(function() {
		$(this).next().toggle(500);
		return false;
	});
	
   
   	// Confirma exclusão de vagas
	$(".excluir").click( function() {	
		var url = $(this).attr('href');
		var confirma = confirm('Apagar essa vaga?');
		if (confirma){
			location.href = url;
		}
		return false;
	});


	
}); // Fim do ready
