jQuery(document).ready(function() {

	jQuery("#formlogin").submit(function() {
		$("#recado").html("");
		if (jQuery("#senhalogin").val()) {
			$("#senhalogin").css("background", "#fff");
		} else {
			$("#senhalogin").css("background-color", "red");
			$("#recado").fadeIn("slow").html("A senha deve ser informada");
			return false;
		}
		if (jQuery("#loginlogin").val()) {
			$("#loginlogin").css("background", "#fff");
		} else {
			$("#loginlogin").css("background-color", "red");
			$("#recado").fadeIn("slow").html("O login deve ser informado");
			return false;
		}
	});

	jQuery("#submit_login").click(function() {
		if (!jQuery(".login").val()) {
			jQuery("#alerta_conexao").html("Login deve ser informado");
			return false;
		} else if (jQuery(".senha").val() == "") {
			jQuery("#alerta_conexao").html("Senha deve ser informada");
			return false;
		} else {
			
			$("#submit_login").hide();
			var login = jQuery(".login").val();
			var senha = jQuery(".senha").val();
			var condominio = jQuery(".condominio").val();
			
			jQuery.post('ajaxRequest.php', {
				login : login,
				senha : senha,
				condominio : condominio,
				arquivo : 'restrito/usuario/login/verifica_usuario.php'
			}, function(login) {
				if (login) {
					// jQuery("#alerta_conexao").html(login);
					$("#submit_login").show();
					alert(login);
				} else {
					window.location.reload(true);
				}
			});
		}

	});

});
