LG.updatepassword = function () {
    $(document).bind('keydown.updatepassword', function (e) {
        if (e.keyCode == 13) {
            doChangePassword();
        }
    });

    if (!window.changePasswordWin) {

        var changePasswordPanle = $("#modifypwdForm");
        changePasswordPanle.ligerForm({
            inputWidth: 140,
            fields: [
                { display: '旧密码',name: 'OldPassword',type: 'password',validate: { maxlength: 50, required: true, messages: { required: '请输入密码'}} },
                { display: '新密码', name: 'NewPassword', type: 'password', validate: { maxlength: 50, required: true, messages: { required: '请输入密码'}} },
                { display: '确认密码', name: 'NewPassword2', type: 'password', validate: { maxlength: 50, required: true, equalTo: 'input[name="NewPassword"]', messages: { required: '请输入密码', equalTo: '两次密码输入不一致'}} }
            ]
        });

        //验证
        jQuery.metadata.setType("attr", "validate");
        LG.validate(changePasswordPanle);

        window.changePasswordWin = $.ligerDialog.open({
            width: 320,
            height: 160, top: 160,
            isResize: true,
            title: '用户修改密码',
            target: $("#modifyPwd"),
            buttons: [
            { text: '确定', onclick: function () {
                doChangePassword();
            }
            },
            { text: '取消', onclick: function () {
                window.changePasswordWin.hide();
                $(document).unbind('keydown.updatepassword');
            }
            }
            ]
        });
    }
    else {
        window.changePasswordWin.show();
    }

    function doChangePassword() {
        var OldPassword = liger.get("OldPassword").getValue();
        var LoginPassword = liger.get("NewPassword").getValue();

        if (changePasswordPanle.valid()) {
            $.ajax({
                type: "get",
                url: 'ModifyPwd.ashx',
                data: { OldPassword: OldPassword, LoginPassword: LoginPassword },
                cache: false,
                async: false,
                success: function (result) {
                    var obj_result = eval('(' + result + ')');   //返回信息 {'success':true}
                    if (obj_result.success == true) {
                        LG.showSuccess('密码修改成功');
                        window.changePasswordWin.hide();
                        $(document).unbind('keydown.updatepassword');
                    }
                    else {
                        if (obj_result.success == "notpwd") {
                            LG.tip('你输入的旧密码不正确！');
                        }
                        else {
                            LG.showError('修改密码失败！');
                        }

                    }
                }
            });

        }
    }

};     