$("document").ready(function(){$("#login-form").validate({rules:{password:{required:!0},user:{required:!0}},messages:{password:{required:"Password is Required."},user:{required:"Username is Required."}},errorPlacement:function(e,r){$(r).closest(".form-group").find(".help-block").html(e.html())},highlight:function(e){$(e).closest(".form-group").removeClass("has-success").addClass("has-error")},unhighlight:function(e,r,o){$(e).closest(".form-group").removeClass("has-error"),$(e).closest(".form-group").find(".help-block").html("")},submitHandler:function(){$.ajax({url:"functions/login_validate.php",type:"POST",data:$("#login-form").serialize(),dataType:"json"}).done(function(e){$("#btn-login").html("LOGIN...").prop("disabled",!0),$("input[type=text],input[type=password]").prop("disabled",!0),setTimeout(function(){"ok"===e.status?"staff"===e.acc_type?setTimeout('window.location.href = "user_acc/staff/"; ',3):"contr"===e.acc_type&&setTimeout('window.location.href = "user_acc/contractor/"; ',3):$("#errorDiv").slideDown("fast",function(){$("#errorDiv").html('<div class="alert alert-danger">'+e.message+"</div>"),$("#login-form").trigger("reset"),$("input[type=text],input[type=password]").prop("disabled",!1),$("#btn-login").html("LOGIN").prop("disabled",!1)}).delay(3e3).slideUp("fast")},1e3)}).fail(function(){$("#login-form").trigger("reset"),alert("An unknown error occoured, Please try again Later...")})}})});