<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true"
    CodeBehind="Administrator.aspx.cs" EnableEventValidation="false" ValidateRequest="false"
    Inherits="PowerEasy.Module.General.WebSite.Admin.User.AdministratorUI" Title="管理员添加/修改" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CphNavigation" runat="server">
    <pe:ExtendedSiteMapPath ID="SmpNavigator" SiteMapProvider="AdminMapProvider" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CphContent" runat="server">
    <style>
        /*搜索*/
        .Admin_Search
        {
            margin-top: 3px;
            margin-bottom: 0px;
        }
        .Admin_Searchb, .Admin_Searcha
        {
            background-image: url(../../Admin/Images/SearchN.gif);
            background-repeat: no-repeat;
            cursor: pointer;
            width: 15px;
            height: 15px;
            z-index: 9999;
            position: absolute;
            margin-left: -22px;
            margin-top: 3px;
        }
        .Admin_Searcha
        {
            background-image: url(../../Admin/Images/SearchX.gif);
        }
        .Admin_Search_UpAndDown
        {
            display: none;
        }
    </style>
    <script type="text/javascript" language="javascript">
        var oldvalue, oldvalue2;
        var selectobj, selectobj2;
        var index = 0, index2 = 0;
        var count = 0, count2 = 0;

        function beginsearch(obj) {
            if ($(obj).attr("value") == "快速搜索") {
                $("#Searchb").attr("className", "Admin_Searcha")
                $("#Searchb").bind("click", offsearch);
                $(obj).attr("value", "");
            }
            return true;
        }

        function beginsearch2(obj) {
            if ($(obj).attr("value") == "快速搜索") {
                $("#department_search_btn_lhs").attr("className", "Admin_Searcha")
                $("#department_search_btn_lhs").bind("click", offsearch2);
                $(obj).attr("value", "");
            }
            return true;
        }

        function outsearch(obj) {
            if ($(obj).attr("value") == "") {
                $("#Searchb").attr("className", "Admin_Searchb")
                $(obj).attr("value", "快速搜索");
                $("#Admin_Search_UpAndDown").hide();
                index = 0;
                count = 0;
            }
            return true;
        }

        function outsearch2(obj) {
            if ($(obj).attr("value") == "") {
                $("#department_search_btn_lhs").attr("className", "Admin_Searchb")
                $(obj).attr("value", "快速搜索");
                $("#department_search_upanddown").hide();
                index2 = 0;
                count2 = 0;
            }
            return true;
        }
        function offsearch(obj) {
            $("#Searchb").attr("className", "Admin_Searchb")
            $("#Admin_Search").attr("value", "快速搜索");
            $("#Searchb").unbind();
            index = 0;
            count = 0;
            $("#Admin_Search_UpAndDown").hide();
            return true;
        }

        function offsearch2(obj) {
            $("#department_search_btn_lhs").attr("className", "Admin_Searchb")
            $("#department_search_lhs").attr("value", "快速搜索");
            $("#department_search_btn_lhs").unbind();
            index2 = 0;
            count2 = 0;
            $("#department_search_upanddown").hide();
            return true;
        }
        function Gosearch(obj, event) {
            var searchtext = $("#Admin_Search").val();
            if (searchtext != "") {
                if (searchtext != oldvalue) {
                    var sobj = $("#<%=this.LstNotBelongRole.ClientID %>").find("option:contains('" + searchtext + "')");
                    selectobj = sobj;
                    count = sobj.length;
                    if (count > 0) {
                        sobj.parent().val(sobj.eq(0).val());
                    }
                    if (count > 1) {
                        $("#Admin_Search_UpAndDown").show();
                    } else {
                        $("#Admin_Search_UpAndDown").hide();
                    }
                    oldvalue = searchtext;
                }
            } else {
                oldvalue = "";
                $("#Admin_Search_UpAndDown").hide();
            }
            return true;
        }

        function Gosearch2(obj, event) {
            var searchtext = $("#department_search_lhs").val();
            if (searchtext != "") {
                if (searchtext != oldvalue) {
                    var sobj = $("#<%=LstNotBelongDepartment.ClientID %>").find("option:contains('" + searchtext + "')");
                    selectobj2 = sobj;
                    count2 = sobj.length;
                    if (count2 > 0) {
                        sobj.parent().val(sobj.eq(0).val());
                    }
                    if (count2 > 1) {
                        $("#department_search_upanddown").show();
                    } else {
                        $("#department_search_upanddown").hide();
                    }
                    oldvalue2 = searchtext;
                }
            } else {
                oldvalue2 = "";
                $("#department_search_upanddown").hide();
            }
            return true;
        }

        function searchpre() {
            if (count > 1) {
                index--;
                if (index < 0) {
                    index = count - 1;
                }
                selectobj.parent().val(selectobj.eq(index).val());
            }
        }

        function searchpre2() {
            if (count2 > 1) {
                index2--;
                if (index2 < 0) {
                    index2 = count2 - 1;
                }
                selectobj2.parent().val(selectobj2.eq(index2).val());
            }
        }

        function searchnext() {
            if (count > 1) {
                index++;
                if (index >= count) {
                    index = 0;
                }
                selectobj.parent().val(selectobj.eq(index).val());
            }
        }

        function searchnext2() {
            if (count2 > 1) {
                index2++;
                if (index2 >= count2) {
                    index2 = 0;
                }
                selectobj2.parent().val(selectobj2.eq(index2).val());
            }
        }

        $(document).ready(function () {
            var o = $("#Admin_Search");
            o.bind("keyup", function (event) { Gosearch(this, event); });
            o.bind("blur", function () { outsearch(this); });
            o.bind("focus", function () { beginsearch(this); });
            o.bind("mouseover", function () { $(this).attr("className", 'inputtext_hover'); });
            o.bind("mouseout", function () { $(this).attr("className", 'inputtext'); });
            o.bind("focus", function () { $(this).attr("className", 'inputtext_focus'); });

            var o = $("#department_search_lhs");
            o.bind("keyup", function (event) { Gosearch2(this, event); });
            o.bind("blur", function () { outsearch2(this); });
            o.bind("focus", function () { beginsearch2(this); });
            o.bind("mouseover", function () { $(this).attr("className", 'inputtext_hover'); });
            o.bind("mouseout", function () { $(this).attr("className", 'inputtext'); });
            o.bind("focus", function () { $(this).attr("className", 'inputtext_focus'); });
        });
    </script>
    <script type="text/javascript" language="javascript">
        var oldvalue1, oldvalue3;
        var selectobj1, selectobj3;
        var index1 = 0, index3 = 0;
        var count1 = 0, count3 = 0;

        function beginsearch1(obj1) {
            if ($(obj1).attr("value") == "快速搜索") {
                $("#Searchb1").attr("className", "Admin_Searcha")
                $("#Searchb1").bind("click", offsearch1);
                $(obj1).attr("value", "");
            }
            return true;
        }

        function beginsearch3(obj1) {
            if ($(obj1).attr("value") == "快速搜索") {
                $("#department_search_btn_rhs").attr("className", "Admin_Searcha")
                $("#department_search_btn_rhs").bind("click", offsearch3);
                $(obj1).attr("value", "");
            }
            return true;
        }
        function outsearch1(obj1) {
            if ($(obj1).attr("value") == "") {
                $("#Searchb1").attr("className", "Admin_Searchb")
                $(obj1).attr("value", "快速搜索");
                $("#Admin_Search_UpAndDown1").hide();
                index1 = 0;
                count1 = 0;
            }
            return true;
        }

        function outsearch3(obj1) {
            if ($(obj1).attr("value") == "") {
                $("#department_search_btn_rhs").attr("className", "Admin_Searchb")
                $(obj1).attr("value", "快速搜索");
                $("#department_search_upanddown1").hide();
                index3 = 0;
                count3 = 0;
            }
            return true;
        }
        function offsearch1(obj1) {
            $("#Searchb1").attr("className", "Admin_Searchb")
            $("#Admin_Search1").attr("value", "快速搜索");
            $("#Searchb1").unbind();
            index1 = 0;
            count1 = 0;
            $("#Admin_Search_UpAndDown1").hide();
            return true;
        }

        function offsearch3(obj1) {
            $("#department_search_btn_rhs").attr("className", "Admin_Searchb")
            $("#department_search_rhs").attr("value", "快速搜索");
            $("#department_search_btn_rhs").unbind();
            index1 = 0;
            count1 = 0;
            $("#department_search_upanddown1").hide();
            return true;
        }
        function Gosearch1(obj1, event1) {
            var searchtext1 = $("#Admin_Search1").val();
            if (searchtext1 != "") {
                if (searchtext1 != oldvalue1) {
                    var sobj1 = $("#<%=this.LstBelongToRole.ClientID %>").find("option:contains('" + searchtext1 + "')");
                    selectobj1 = sobj1;
                    count1 = sobj1.length;
                    if (count1 > 0) {
                        sobj1.parent().val(sobj1.eq(0).val());
                    }
                    if (count1 > 1) {
                        $("#Admin_Search_UpAndDown1").show();
                    } else {
                        $("#Admin_Search_UpAndDown1").hide();
                    }
                    oldvalue1 = searchtext1;
                }
            } else {
                oldvalue1 = "";
                $("#Admin_Search_UpAndDown1").hide();
            }
            return true;
        }

        function Gosearch3(obj1, event1) {
            var searchtext1 = $("#department_search_rhs").val();
            if (searchtext1 != "") {
                if (searchtext1 != oldvalue1) {
                    var sobj1 = $("#<%=this.LstBelongToDepartment.ClientID %>").find("option:contains('" + searchtext1 + "')");
                    selectobj3 = sobj1;
                    count3 = sobj1.length;
                    if (count3 > 0) {
                        sobj1.parent().val(sobj1.eq(0).val());
                    }
                    if (count3 > 1) {
                        $("#department_search_upanddown1").show();
                    } else {
                        $("#department_search_upanddown1").hide();
                    }
                    oldvalue3 = searchtext1;
                }
            } else {
                oldvalue3 = "";
                $("#department_search_upanddown1").hide();
            }
            return true;
        }

        function searchpre1() {
            if (count1 > 1) {
                index1--;
                if (index1 < 0) {
                    index1 = count1 - 1;
                }
                selectobj1.parent().val(selectobj1.eq(index1).val());
            }
        }

        function searchpre3() {
            if (count3 > 1) {
                index3--;
                if (index3 < 0) {
                    index3 = count3 - 1;
                }
                selectobj3.parent().val(selectobj3.eq(index3).val());
            }
        }

        function searchnext1() {
            if (count1 > 1) {
                index1++;
                if (index1 >= count1) {
                    index1 = 0;
                }
                selectobj1.parent().val(selectobj1.eq(index1).val());
            }
        }

        function searchnext3() {
            if (count3 > 1) {
                index3++;
                if (index3 >= count3) {
                    index3 = 0;
                }
                selectobj3.parent().val(selectobj3.eq(index3).val());
            }
        }

        $(document).ready(function () {
            var obj = $("#Admin_Search1");
            obj.bind("keyup", function (event1) { Gosearch1(this, event1); });
            obj.bind("blur", function () { outsearch1(this); });
            obj.bind("focus", function () { beginsearch1(this); });
            obj.bind("mouseover", function () { $(this).attr("className", 'inputtext_hover'); });
            obj.bind("mouseout", function () { $(this).attr("className", 'inputtext'); });
            obj.bind("focus", function () { $(this).attr("className", 'inputtext_focus'); });

            var obj = $("#department_search_rhs");
            obj.bind("keyup", function (event1) { Gosearch3(this, event1); });
            obj.bind("blur", function () { outsearch3(this); });
            obj.bind("focus", function () { beginsearch3(this); });
            obj.bind("mouseover", function () { $(this).attr("className", 'inputtext_hover'); });
            obj.bind("mouseout", function () { $(this).attr("className", 'inputtext'); });
            obj.bind("focus", function () { $(this).attr("className", 'inputtext_focus'); });
        });
    </script>
    <asp:ScriptManager ID="SmgeRegion" runat="server" EnablePartialRendering="true">
    </asp:ScriptManager>
    <table width="100%" border="0" cellpadding="2" cellspacing="1" class="border">
        <tr align="center">
            <td colspan="2" class="spacingtitle">
                <b>
                    <pe:AlternateLiteral ID="LblTitle" Text="添加管理员" AlternateText="修改管理员" runat="Server" /></b>
            </td>
        </tr>
        <tr class="tdbg">
            <td class="tdbgleft">
                <strong>管理员名：</strong>
            </td>
            <td>
                <asp:TextBox ID="TxtAdminName" runat="server"></asp:TextBox>
                <pe:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TxtAdminName"
                    ErrorMessage="管理员名不能为空！" Display="Dynamic" runat="server"></pe:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="ValgTextMaxLength" Display="Dynamic" ControlToValidate="TxtAdminName"
                    ValidationExpression="^[a-zA-Z0-9_\u4e00-\u9fa5]{2,20}$" SetFocusOnError="true"
                    runat="server" ErrorMessage="管理员名必须大于2个字符并且不能超过20个字符，并只能包含字母、数字、中文字符！"></asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr class="tdbg">
            <td class="tdbgleft">
                <strong>前台会员名</strong>（<pe:ExtendedHyperLink ID="HypAddUser" NavigateUrl="~/Admin/User/User.aspx?Administrator=true"
                    BeginTag="<strong><span style='color:Blue;'>" EndTag="</span></strong>" runat="server">添加</pe:ExtendedHyperLink>）：
            </td>
            <td>
                <asp:TextBox ID="TxtUserName" runat="server"></asp:TextBox>
                <pe:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="TxtUserName"
                    ErrorMessage="前台会员名不能为空！" runat="server"></pe:RequiredFieldValidator>
            </td>
        </tr>
        <tr class="tdbg">
            <td class="tdbgleft">
                <strong>填写密码：</strong>
            </td>
            <td>
                <asp:TextBox ID="TxtPassword" runat="server" TextMode="Password" onkeyup="isSecurity(this.value);"
                    onblur="Bardisplaynone();" onfocus="Bardisplayshow();"></asp:TextBox><pe:ExtendedLabel
                        HtmlEncode="false" ID="LabTip" runat="server"></pe:ExtendedLabel>
                <pe:RequiredFieldValidator ID="ValrPassword" ControlToValidate="TxtPassword" runat="server"
                    ErrorMessage="密码不能为空！" Display="Dynamic"></pe:RequiredFieldValidator>
                <span id="BarBorder_TxtUserPassword"></span>
                <asp:Label Text="" runat="server" ID="LabelStrongPwd" />
            </td>
        </tr>
        <tr class="tdbg" runat="server" id="TrPassword">
            <td class="tdbgleft">
                <strong>确认密码：</strong>
            </td>
            <td>
                <asp:TextBox ID="TxtPassword2" runat="server" TextMode="Password"></asp:TextBox>
                <asp:CompareValidator ID="CompareValTxtPassword" ControlToValidate="TxtPassword2"
                    ControlToCompare="TxtPassword" Display="Dynamic" ErrorMessage="两次输入的密码不一致！" runat="server"></asp:CompareValidator><pe:RequiredFieldValidator
                        ID="ValrPassword2" ControlToValidate="TxtPassword2" runat="server" ErrorMessage="确认密码不能为空！"
                        Display="Dynamic"></pe:RequiredFieldValidator>
            </td>
        </tr>
        <tr class="tdbg">
            <td class="tdbgleft">
                <strong>角色设置：</strong>
            </td>
            <td>
                <asp:CheckBox runat="server" ID="ChkPurview1" Text="" />超级管理员：拥有所有权限。某些权限（如管理员管理、网站信息配置、角色管理等管理权限）只有超级管理员才有。<br />
                <asp:CheckBox runat="server" ID="ChkPurview2" Text="" Checked="true" />普通管理员：需要详细指定每一项角色权限。
            </td>
        </tr>
        <tr class="tdbg" runat="server" id="RolePurview">
            <td class="tdbgleft">
            </td>
            <td style="height: 100px">
                <br />
                <table border="0" cellspacing="0" cellpadding="0">
                    <tr align="center">
                        <td valign="top" align="left" style="width: 258px; padding-left: 5px;">
                            <strong>可选角色</strong><br />
                            <div class="Admin_Search">
                                <input id="Admin_Search" value="快速搜索" class="inputtext" style="width: 248px;" />
                                <a id="Searchb" class="Admin_Searchb"></a>
                            </div>
                            <asp:ListBox ID="LstNotBelongRole" runat="server" Height="300px" Width="250px" DataTextField="RoleName"
                                DataValueField="RoleId" SelectionMode="Multiple"></asp:ListBox>
                        </td>
                        <td style="width: 100px;" align="center">
                            <span id="Admin_Search_UpAndDown" class="Admin_Search_UpAndDown">
                                <input id="Button4" value="上一个" type="button" onclick="searchpre()" /><br />
                                &nbsp;<br />
                                <input id="Button3" value="下一个" type="button" onclick="searchnext()" />
                            </span>
                            <input type="button" class="inputbutton" value="添加>>" onclick="JavaScript:addItem(<%=LstNotBelongRole.ClientID%>,<%=LstBelongToRole.ClientID%>);delItem(<%=LstNotBelongRole.ClientID%>)" /><br />
                            <br />
                            <input type="button" class="inputbutton" value="<<移除" onclick="JavaScript:addItem(<%=LstBelongToRole.ClientID%>,<%=LstNotBelongRole.ClientID%>);delItem(<%=LstBelongToRole.ClientID%>)" />
                        </td>
                        <td valign="top" align="left" style="width: 258px; padding-left: 5px;">
                            <strong>所属角色</strong><br />
                            <div class="Admin_Search">
                                <input id="Admin_Search1" value="快速搜索" class="inputtext" style="width: 248px;" />
                                <a id="Searchb1" class="Admin_Searchb"></a>
                            </div>
                            <asp:ListBox ID="LstBelongToRole" runat="server" Height="300px" Width="250px" DataTextField="RoleName"
                                DataValueField="RoleId" SelectionMode="Multiple" ondblclick="lookPower()"></asp:ListBox>
                            <asp:HiddenField ID="HdnBelongToRole" runat="server" />
                            <span id="Admin_Search_UpAndDown1" class="Admin_Search_UpAndDown" style="position: absolute;">
                                <input id="Button1" value="上一个" type="button" onclick="searchpre1()" /><br />
                                &nbsp;<br />
                                <input id="Button2" value="下一个" type="button" onclick="searchnext1()" />
                            </span>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr class="tdbg">
            <td class="tdbgleft">
                <strong>部门设置：</strong>
            </td>
            <td>
                <br />
                <table border="0" cellspacing="0" cellpadding="0">
                    <tr align="center">
                        <td valign="top" align="left" style="width: 258px; padding-left: 5px;">
                            <strong>可选部门</strong><br />
                            <div class="Admin_Search">
                                <input id="department_search_lhs" value="快速搜索" class="inputtext" style="width: 248px;" />
                                <a id="department_search_btn_lhs" class="Admin_Searchb"></a>
                            </div>
                            <asp:ListBox ID="LstNotBelongDepartment" runat="server" Height="300px" Width="250px"
                                DataTextField="DepartmentName" DataValueField="DepartmentId" SelectionMode="Multiple">
                            </asp:ListBox>
                        </td>
                        <td style="width: 100px;" align="center">
                            <span id="department_search_upanddown" class="Admin_Search_UpAndDown">
                                <input id="Button5" value="上一个" type="button" onclick="searchpre2()" /><br />
                                &nbsp;<br />
                                <input id="Button6" value="下一个" type="button" onclick="searchnext2()" />
                            </span>
                            <input type="button" class="inputbutton" value="添加>>" onclick="JavaScript:addDepartmentItem(<%=LstNotBelongDepartment.ClientID%>,<%=LstBelongToDepartment.ClientID%>);disabledItem(<%=LstNotBelongDepartment.ClientID%>)" /><br />
                            <br />
                            <input type="button" class="inputbutton" value="<<移除" onclick="JavaScript:unDisabledItem(<%=LstBelongToDepartment.ClientID%>,<%=LstNotBelongDepartment.ClientID%>);delItem(<%=LstBelongToDepartment.ClientID%>)" />
                        </td>
                        <td valign="top" align="left" style="width: 258px; padding-left: 5px;">
                            <strong>所属部门</strong><br />
                            <div class="Admin_Search">
                                <input id="department_search_rhs" value="快速搜索" class="inputtext" style="width: 248px;" />
                                <a id="department_search_btn_rhs" class="Admin_Searchb"></a>
                            </div>
                            <asp:ListBox ID="LstBelongToDepartment" runat="server" Height="300px" Width="250px"
                                DataTextField="DepartmentName" DataValueField="DepartmentId" SelectionMode="Multiple">
                            </asp:ListBox>
                            <asp:HiddenField ID="HdnBelongToDepartment" runat="server" />
                            <span id="department_search_upanddown1" class="Admin_Search_UpAndDown" style="position: absolute;">
                                <input id="Button7" value="上一个" type="button" onclick="searchpre3()" /><br />
                                &nbsp;<br />
                                <input id="Button8" value="下一个" type="button" onclick="searchnext3()" />
                            </span>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr class="tdbg">
            <td class="tdbgleft">
                <strong>选项设置：</strong>
            </td>
            <td>
                <asp:CheckBox ID="ChkEnableMultiLogin" runat="server" />允许多人同时使用此帐号登录<br />
                <asp:CheckBox ID="ChkEnableModifyPassword" runat="server" Checked="true" />允许管理员修改密码<br />
                <asp:CheckBox ID="ChkIsLock" runat="server" />是否锁定
            </td>
        </tr>
        <tr class="tdbg" align="center">
            <td colspan="2">
                <asp:Button ID="BtnSubmit" runat="server" Text="提交信息" OnClick="BtnSubmit_Click" />&nbsp;&nbsp;
                <asp:Button ID="BtnCancle" runat="server" Text="取消" OnClick="BtnCancle_Click" ValidationGroup="BtnCancel" />
            </td>
        </tr>
    </table>
    <script type="text/javascript">

        function lookPower() {
            var strUrl;
            var lst = document.getElementById("<%=LstBelongToRole.ClientID %>");
            var value = lst.value;
            strUrl = "User/RolePermissions.aspx?Action=Modify&RoleId=" + value + "";
            var pe = new parent.PE_FrameTab.AddNew(strUrl);
            if (pe == null) {
                alert("AddNewTab Error!");
            }

        }

        $('#<%=ChkPurview2.ClientID %>').click(function () {
            var chk = document.getElementById("<%=RolePurview.ClientID%>").style.display;
            if (chk == "none") {
                this.checked = true;
                document.getElementById("<%=RolePurview.ClientID%>").style.display = "";
            } else {
                this.checked = false;
                document.getElementById("<%=RolePurview.ClientID%>").style.display = "none";
            }
        })

        /**
        * add one option of a select to another select.
        *
        * @author  Chunsheng Wang <wwccss@263.net>
        */
        function addItem(ItemList, Target) {
            for (var x = 0; x < ItemList.length; x++) {
                var opt = ItemList.options[x];
                if (opt.selected) {
                    flag = true;
                    for (var y = 0; y < Target.length; y++) {
                        var myopt = Target.options[y];
                        if (myopt.value == opt.value) {
                            flag = false;
                        }
                    }
                    if (flag) {
                        Target.options[Target.options.length] = new Option(opt.text, opt.value, 0, 0);
                    }
                }
            }
        }

        /**
        * add one option of a select to another select.
        *
        * @author  Chunsheng Wang <wwccss@263.net>
        */
        function addDepartmentItem(ItemList, Target) {
            for (var x = 0; x < ItemList.length; x++) {
                var opt = ItemList.options[x];
                if (opt.selected) {
                    flag = true;
                    for (var y = 0; y < Target.length; y++) {
                        var myopt = Target.options[y];
                        if (myopt.value == opt.value) {
                            flag = false;
                        }
                    }
                    if (flag) {
                        Target.options[Target.options.length] = new Option(opt.text.replace(/└/g, "").replace(/├/g, "").replace(/├/g, "").replace(/\s/g, "").replace(/│/g, ""), opt.value, 0, 0);
                    }
                }
            }
        }

        /**
        * add one option of a select to another select.
        *
        * @author  Chunsheng Wang <wwccss@263.net>
        */
        function disabledItem(ItemList) {
            for (var x = 0; x < ItemList.length; x++) {
                var opt = ItemList.options[x];
                if (opt.selected) {
                    opt.disabled = true;
                    opt.selected = false;
                    opt.setAttribute("style", "background:#ccc;");
                }
            }
        }

        function unDisabledItem(ItemList, Target) {
            for (var x = 0; x < ItemList.length; x++) {
                var opt = ItemList.options[x];
                if (opt.selected) {
                    for (var y = 0; y < Target.length; y++) {
                        var myopt = Target.options[y];
                        if (myopt.value == opt.value) {
                            myopt.disabled = false;
                            
                            myopt.setAttribute("style", "");
                        }
                    }
                }
            }
        }

        /**
        * move one selected option from a select.
        *
        * @author  Chunsheng Wang <wwccss@263.net>
        */
        function delItem(ItemList) {
            for (var x = ItemList.length - 1; x >= 0; x--) {
                var opt = ItemList.options[x];
                if (opt.selected) {
                    ItemList.options[x] = null;
                }
            }
        }

        function GetBelongToRole(ItemList,DepartMentList) {
            var adminId = "";
            for (var x = 0; x < ItemList.length; x++) {
                if (adminId == "") {
                    adminId = ItemList.options[x].value;
                }
                else {
                    adminId += "," + ItemList.options[x].value;
                }
            }
            var belongToRole = document.getElementById("<%=HdnBelongToRole.ClientID%>");
            belongToRole.value = adminId;
            var departmentIds = "";
            for (var i = 0; i < DepartMentList.length; i++) {
                if (departmentIds == "") {
                    departmentIds = DepartMentList.options[i].value;
                }
                else {
                    departmentIds += "," + DepartMentList.options[i].value;
                }
            }
            var belongToDepartment = document.getElementById("<%=HdnBelongToDepartment.ClientID%>");
            belongToDepartment.value = departmentIds;
        }
    </script>
</asp:Content>
