<%@ page language="C#" autoeventwireup="true" inherits="e_role_do, ZKCMS" enableviewstatemac="false" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register TagName="meta" TagPrefix="UC" Src="~/e/meta.ascx" %>
<%@ Register TagName="head" TagPrefix="UC" Src="~/e/head.ascx" %>
<%@ Register TagName="foot" TagPrefix="UC" Src="~/e/foot.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <UC:meta ID="meta1" runat="server" />
</head>
<body>
    <form id="form1" runat="server" autocomplete="off">
    <asp:Label ID="pathcode" runat="server" Style="display: none">
    &nbsp;&raquo;&nbsp;系统设置&nbsp;&raquo;&nbsp;角色设置
    </asp:Label>
    <UC:head ID="head1" runat="server" />
    <%--main start--%>
    <div class="c1">
        <div class="b1">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="b1_l">
                    </td>
                    <td>
                        <div class="con1">
                            <ul>
                                <li class="on"><a href="role.aspx">角色设置</a></li>
                                <li style="width: 80px"><a href="administrator.aspx">管理员设置</a></li>
                            </ul>
                            <div class="clear">
                            </div>
                        </div>
                    </td>
                    <td align="right">
                        <div class="con2">
                        </div>
                    </td>
                    <td class="b1_r">
                    </td>
                </tr>
            </table>
        </div>
        <div class="v1">
            <div class="do1">

                <script type="text/javascript">
function check(){
var n=document.getElementById("n").value;
var note=document.getElementById("note").value;
if(n==""){alert("请输入角色名！");return false;}
if(n.toLowerCase()=="super"){alert("已存在系统默认角色，请匆重复添加！");return false;}
if(note!=""&&note.length>100){alert("备注长度超出限制！");return false;}
if(document.getElementById("newvalue").value==""){alert("请设置权限！");return false;}
}
                </script>

                <table border="0" cellpadding="0" cellspacing="0" class="table1">
                    <tr>
                        <td class="tt">
                            <b>角色名：</b>
                        </td>
                        <td>
                            <asp:TextBox ID="n" runat="server" MaxLength="10" CssClass="inp1" Width="300" autocomplete="off"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tt">
                            备注：
                        </td>
                        <td>
                            <asp:TextBox ID="note" runat="server" TextMode="MultiLine" CssClass="inp1" Width="300"
                                Height="100" autocomplete="off"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="tt">
                            <b>设置权限：</b>
                        </td>
                        <td>

                            <script type="text/javascript">

function selRole(obj,hierarchy,str)
{document.getElementById("divcodecopy").style.display="";
if(hierarchy==0){var arr1=str.split(",");for(var i=0;i<arr1.length;i++){if(i!=0&&arr1[i]!="")if(obj.checked==true){document.getElementById(arr1[i].substring(0,arr1[i].indexOf(".aspx")+5)).checked=true;if(document.getElementById("newvalue").value.indexOf(document.getElementById(arr1[i].substring(0,arr1[i].indexOf(".aspx")+5)).id+",")==-1){document.getElementById("newvalue").value+=document.getElementById(arr1[i].substring(0,arr1[i].indexOf(".aspx")+5)).id+",";}if(document.getElementById("newvalue").value.indexOf(obj.id+",")==-1){document.getElementById("newvalue").value+=obj.id+",";}}else {document.getElementById(arr1[i].substring(0,arr1[i].indexOf(".aspx")+5)).checked=false;document.getElementById("newvalue").value=document.getElementById("newvalue").value.replace(obj.id+",","").replace(document.getElementById(arr1[i].substring(0,arr1[i].indexOf(".aspx")+5)).id+",","");}}}
else{
if(obj.checked==true){document.getElementById(obj.className).checked=true;if(document.getElementById("newvalue").value.indexOf(obj.id+",")==-1){document.getElementById("newvalue").value+=obj.id+",";}if(document.getElementById("newvalue").value.indexOf(document.getElementById(obj.className).id+",")==-1){document.getElementById("newvalue").value+=document.getElementById(obj.className).id+",";}}
else{
document.getElementById("newvalue").value=document.getElementById("newvalue").value.replace(obj.id+",","");
var N=0;var str1=document.getElementById(obj.className).parentNode.innerHTML;str1=str1.substring(str1.indexOf(",0")+8);str1=str1.substring(0,str1.indexOf("\')\""));
var arr1=str1.split(",");for(var i=0;i<arr1.length;i++){if(i!=0&&arr1[i]!=""){if(document.getElementById(arr1[i].substring(0,arr1[i].indexOf(".aspx")+5)).checked==true)N++;}}
if(N==0){document.getElementById(obj.className).checked=false;document.getElementById("newvalue").value=document.getElementById("newvalue").value.replace(document.getElementById(obj.className).id+",","");}
}
}
var ctl = document.getElementById("divcode"); var BakCode=ctl.innerHTML;var checkbox = ctl.getElementsByTagName("input");
for(var j=0;j<checkbox.length;j++){if(checkbox[j].type=="checkbox"){if(checkbox[j].checked==false)checkbox[j].parentNode.style.display="none";}}
document.getElementById("divcodecopy").innerHTML=document.getElementById("divcode").innerHTML.replace("id","iid").replace("ID","IID").replace(/<input/g,"<input disabled=\"disabled\"").replace(/<INPUT/g,"<input disabled=\"disabled\"").replace(/<input/g,"<input checked=\"checked\"").replace(/<INPUT/g,"<input checked=\"checked\"");document.getElementById("divcode").innerHTML=BakCode;
var arr0=document.getElementById("newvalue").value.split(",");for(var M=0;M<arr0.length;M++){if(arr0[M]!=""){if(document.getElementById(arr0[M]))document.getElementById(arr0[M]).checked=true;}}
if(arr0.length==1)document.getElementById("divcodecopy").style.display="none";
}

                            </script>

                            <table border="0" cellpadding="0" cellspacing="0" class="RoleSetBox">
                                <tr>
                                    <td>
                                        <div id="divcode" class="inp1" style="width: 300px; height: 600px; overflow-y: scroll;">
                                            <asp:Literal ID="literalcode" runat="server"></asp:Literal></div>
                                    </td>
                                    <td style="padding-left: 10px">
                                        <asp:HiddenField ID="newvalue" runat="server" />
                                        <div id="divcodecopy" class="inp1" style="width: 300px; height: 600px; overflow-y: scroll;
                                            display: none">
                                        </div>
                                    </td>
                                </tr>
                            </table>

                            <script type="text/javascript">
                            var arr0=document.getElementById("newvalue").value.split(",");for(var M=0;M<arr0.length;M++){if(arr0[M]!=""){if(document.getElementById(arr0[M]))document.getElementById(arr0[M]).checked=true;}}                            
                            </script>

                        </td>
                    </tr>
                    <tr>
                        <td class="tt">
                            &nbsp;
                        </td>
                        <td>
                            <asp:Button ID="ButtonSubmit" runat="server" CssClass="but1" Text="添加" OnClick="ButtonSubmit_Click"
                                OnClientClick="return check()" /><input class="but1" style="margin-left: 10px" type="button"
                                    value="返回" onclick="history.back()" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <%--main end--%>
    <UC:foot ID="foot1" runat="server" />
    </form>
</body>
</html>
