var URI = "http://www.fpbv.com.br/gerenciador/";
/**
 * Chama arquivo de login pelo thinkbox
 */
function showLogin(url){
	tb_show('Logar', url+'loginModal.php?height=85&width=250&modal=true', null);
}

function cancelLogin(){
	tb_remove();
	location.replace(URI+"logar.php");
}

$(function(){
	$("#logou").click(function(){
		if($("#username").val() != "" && $("#password").val() != ""){
			$.ajax({
				type: "POST",
				url:  URI+"logou.php",
				data: "username="+$("#username").val()+"&password="+$("#password").val(),
				success: function(res){
					if(res == '1') tb_remove();
					else $("#stat").html(res);
				}
			});
		}else{
			$("#stat").html("Preencha os campos corretamente.");
		}
	});
});

$(function(){
	$("#log").click(function(){
		if($("#username").val() != "" && $("#password").val() != ""){
			$.ajax({
				type: "POST",
				url:  URI+"logou.php",
				data: "username="+$("#username").val()+"&password="+$("#password").val(),
				success: function(res){
					if(res == '1') location.replace("./");
					else $("#status").html(res);
				}
			});
		}else{
			$("#status").html("Preencha os campos corretamente.");
		}
	});
});