var Login = function(url){
	this.baseUrl=url;
	this.go=function(){
		$("#login-username").attr("disabled","disabled");
		$("#login-password").attr("disabled","disabled");
		$("#login-btn").attr("disabled","disabled");
		
		if($("#login-username").val()=="" || $("#login-password").val()==""){
			toastr.options = {
			  "closeButton": true,
			  "progressBar": true,
			  "positionClass": "toast-top-center"
			}
			toastr.error('Especifique un usuario y una contrase&ntilde;a para poder ingresar');
			$("#login-username").removeAttr("disabled");
			$("#login-password").removeAttr("disabled");
			$("#login-btn").removeAttr("disabled");
			$("#login-username").focus();
		}else{
			 $.post(this.baseUrl+"login/check",{username:$.trim($("#login-username").val()),password:$.trim($("#login-password").val())}, function(response){
				if(response=="true"){
					$("#login-username").removeAttr("disabled");
					$("#login-password").removeAttr("disabled");
					$("#login-form").submit();
				}else{
					toastr.options = {
					  "closeButton": true,
					  "progressBar": true,
					  "positionClass": "toast-top-center"
					}
					toastr.error('Usuario o contrase&ntilde;a incorrecta, por favor verifique.');
					$("#login-username").removeAttr("disabled");
					$("#login-password").removeAttr("disabled");
					$("#login-password").val("");
					$("#login-btn").removeAttr("disabled");
					$("#login-username").select();
				}
			 },"text")
		}
	}
}