// JavaScript Document
$(function(){
	$("#logaok").click(function(){
		var senha 	= document.getElementById("senhaLog");
		var creci	= document.getElementById("creciLog");
		
		$("#logLoad")
		.ajaxStart(function(){
			$(this).show();
		 })
		.ajaxComplete(function(){
			$(this).hide().fadeOut("slow");
		});
		
		$.ajax({
			type: "POST",
			url: "restrito/logar.php",
			data: "creci="+creci.value+"&senha="+senha.value,
			success: function(res){
				if( res == 0 ){
					alert('Usuário ou senha inválido(s)');
					senha.value = '';
					creci.value = '';
				}else{ location.replace('restrito/'); }
			}
		});
	});
});