$(document).ready( function(){
  var PasswordInput = $("input[name=Password]", $("#SignInForm")).focus();
  $("#SignInForm").submit( function(){
    var self = this;
    $.ajax( {
      dataType :'json',
      type :"POST",
      url :$(self).attr("action"),
      data :$("input[name]", $(self)).serialize(),
      success : function(response){
        if (response.error == 0) {
          document.location.href = '/console.html';
        }
        else
          if (response.error == 1) {
            alert('用户密码错误!');
            PasswordInput.val('').focus();
          }
          else
            if (response.error == 2) {
              PasswordInput.val('');
              if (window.confirm('用户密码过于简单,请修改密码后再登录后台;\n您现在要修改密码吗?')) {
                location.href = '/index.php?apps=console&func=password';
              }
            }
      },
      error : function(a, b, c){
        alert(a.responseText);
      }
    });
    return false;
  });
});
if (top.location != self.location) {
  top.location = self.location;
}