{include file="public/header" /}
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>权限设置</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <form method="post" id="admin_form">
        <div  class="ncap-form-default">
            <dl>
                <dt>{$Think.lang.admin_index_username}</dt>
                <dd>
                    {$admin.admin_name}
                    <span class="err"></span>
                    <p class="notic">{$Think.lang.admin_add_username_tip}</p>
                </dd>
            </dl>
            <dl>
                <dt>{$Think.lang.admin_edit_admin_pw}</dt>
                <dd>
                    <input id="new_pw" name="new_pw" value="" class="input-txt" type="password">
                    <span class="err"></span>
                    <p class="notic">{$Think.lang.admin_edit_pwd_tip1}</p>
                </dd>
            </dl>
            <dl>
                <dt>{$Think.lang.admin_edit_admin_pw2}</dt>
                <dd>
                    <input id="new_pw2" name="new_pw2" value="" class="input-txt" type="password">
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl>
                <dt>{$Think.lang.gadmin_name}</dt>
                <dd>
                    <select name="gid">
                        <?php foreach((array)$gadmin as $v){?>
                        <option value="<?php echo $v['gid'];?>"><?php echo $v['gname'];?></option>
                        <?php }?>
                    </select>
                    <span class="err"></span>
                    <p class="notic">{$Think.lang.admin_add_gid_tip}</p>
                </dd>
            </dl>
            <dl>
                <dt></dt>
                <dd><a href="JavaScript:void(0);" class="btn" id="submitBtn">确认提交</a></dd>
            </dl>
        </div>
    </form>
</div>

<script>
//按钮先执行验证再提交表单
                    $(function() {
                        $("#submitBtn").click(function() {
                            if ($("#admin_form").valid()) {
                                $("#admin_form").submit();
                            }
                        });
                    });
                    $(document).ready(function() {
                        $("#admin_form").validate({
                            errorPlacement: function(error, element) {
                                error.appendTo(element.nextAll('span.err'));
                            },
                            rules: {
                                new_pw: {
                                    minlength: 6,
                                    maxlength: 20
                                },
                                new_pw2: {
                                    minlength: 6,
                                    maxlength: 20,
                                    equalTo: '#new_pw'
                                },
                                gid: {
                                    required: true
                                }
                            },
                            messages: {
                                new_pw: {
                                    minlength: '{$Think.lang.admin_add_password_max}',
                                    maxlength: '{$Think.lang.admin_add_password_max}'
                                },
                                new_pw2: {
                                    minlength: '{$Think.lang.admin_add_password_max}',
                                    maxlength: '{$Think.lang.admin_add_password_max}',
                                    equalTo: '{$Think.lang.admin_edit_repeat_error}'
                                },
                                gid: {
                                    required : '{$Think.lang.admin_add_gid_null}',
                                }
                            }
                        });
                    });
</script>