<%@Page Language="C#" Inherits="IWMS.Admin.Power" MasterPageFile="admin.master"%>
<asp:Content ContentPlaceHolderId="cphHead" runat="server">
	<script runat="server">
		string rowFull = "<tr align=\"center\"><td align=\"left\">#name#</td>"+
			"<td width=\"100\"><input type=\"checkbox\" name=\"addnews\" value=\"#id#\"/></td>"+
			"<td width=\"100\"><input type=\"checkbox\" name=\"addnchk\" value=\"#id#\"/></td>"+
			"<td width=\"100\"><input type=\"checkbox\" name=\"setTop\" value=\"#id#\"/></td>"+
			"<td width=\"100\"><input type=\"checkbox\" name=\"chknews\" value=\"#id#\"/></td>"+
			"<td width=\"100\"><input type=\"checkbox\" name=\"chgnews\" value=\"#id#\"/></td>"+
			"<td width=\"100\"><input type=\"checkbox\" name=\"modifync\" value=\"#id#\"/></td></tr>";
		string rowName = "<tr><td align=\"left\" colspan=\"7\">#name#</td></tr>";
	</script>
	<style type="text/css">
	.tblMain
	{
	   behavior:url(inc/scrolltable.htc);
	   background-color: white;
	   border: 1px solid lightblue;
	   font-family: Verdana;
	   font-size: .8em;
	}
	.tblHeader
	{
	   color: #000;
	   height:20px;
	}
	.tblBody
	{
	   background-color: #EEEEEE;
	}
	
	</style>
	<script type="text/javascript">
	<!--
	// 全选分类权限
	function checkAll(chk, name)
	{
		var os=document.getElementsByTagName("INPUT");
		for(var i=0;i<os.length; i++){
			if (os[i].type!="checkbox" || os[i].name!=name){
				continue;
			}
			os[i].checked=chk;
		}
	}
	
	function CheckUPower()
	{
		var objs = document.getElementsByName("power");
		var p = document.getElementById("<%=uPower.ClientID%>").value;
		for(var i=0;i<objs.length;i++){
			var re = new RegExp("(^|,)"+ objs[i].value +"(,|$)", "ig");
			if (re.test(p)){
				objs[i].checked = true;
			}
		}
	}
	
	function GetUPower()
	{
		var objs = document.getElementsByName("power");
		var str = "";
		for(var i=0; i<objs.length; i++){
			if (objs[i].checked){
				if (str.length>0){
					str += ",";
				}
				str += objs[i].value;
			}
		}
		//alert(str);
		document.getElementById("<%=uPower.ClientID%>").value=str;
	}
	
	function CheckSPower()
	{
		var str = document.getElementById("<%=sPower.ClientID%>").value;
		var arr = str.split('\t');
		for(var i=0; i<arr.length; i++){
			var t_arr = arr[i].split('|');
			var objs = document.getElementsByName(t_arr[0]);
			for(var j=0; j<objs.length; j++){
				var re = new RegExp("(^|,)"+ objs[j].value +"(,|$)", "ig");
				if (re.test(t_arr[1])){
					objs[j].checked = true;
				}
			}
		}
	}
	
	function GetSPower()
	{
		var arr = new Array("addnews", "addnchk", "setTop", "chknews", "chgnews", "modifync");
		var str="";
		for(var i=0; i<arr.length; i++){
			var sorts = "";
			if (i==0){
				str = arr[i] +"|";
			}else{
				str += "\t"+ arr[i] +"|";
			}
			var objs = document.getElementsByName(arr[i]);
			for(var j=0; j<objs.length; j++){
				if (objs[j].checked){
					if (sorts.length>0){
						sorts += ",";
					}
					sorts += objs[j].value;
				}
			}
			str += sorts;
		}
	//	alert(str);
		document.getElementById("<%=sPower.ClientID%>").value = str;
	}
	
	$(function(){
		$("#clTable tbody tr").mouseover(function(){
			$(this).toggleClass("tdbg-dark");
		}).mouseout(function(){
			$(this).toggleClass("tdbg-dark");
		});
	});
	-->
	</script>

</asp:Content>
<asp:Content ContentPlaceHolderId="cphMain" runat="server">


	<div class="mframe">
	<div class="tl"></div>
	<div class="rt"></div>
	<div class="tm">
		<span class="tt"><asp:Literal id="ltUser" runat="server"/> 的权限设置</span>
	</div>
	<div class="wrapper">
	<div class="ml"></div>
	<div class="mr"></div>
	<div class="mm">
		<asp:Label id="myLabel" class="msgBar" EnableViewState="false" runat="server"/>
	  <asp:Literal id="Content" runat="server"/>
		<table width="100%" cellpadding="4" cellspacing="0">
		<tr><td class="tdbg-dark">
			全局权限：
			<input type="checkbox" name="power" value="setHighlight" />可设置新闻醒目
			<input type="checkbox" name="power" value="modifyadd" />管理自己添加的新闻&nbsp;
			<input type="checkbox" name="power" value="remarks" />管理评论&nbsp;
			<input type="checkbox" name="power" value="addBulletin" />添加公告&nbsp;
			<input type="checkbox" name="power" value="gatherNews" />采集新闻&nbsp;
			<input type="checkbox" name="power" value="manageLink" />管理友情链接
			<input type="checkbox" name="power" value="managePost" />管理讨论区
		 </td></tr>
		 <tr><td>
		 	<table width="100%" cellpadding="0" cellspacing="3" id="clTable" class="grid">
			<thead class="gridHead">
		 	<tr align="center"><td>
		 	 分类
		 	</td><td width="100">
		 	<input type="checkbox" onclick="checkAll(this.checked,'addnews')"/>添加新闻
		 	</td><td width="100">
		 	<input type="checkbox" onclick="checkAll(this.checked,'addnchk')"/>不需审核
		 	</td><td width="100">
		 	<input type="checkbox" onclick="checkAll(this.checked,'setTop')"/>可设头条固顶
		 	</td><td width="100">
		 	<input type="checkbox" onclick="checkAll(this.checked,'chknews')"/>审核新闻
		 	</td><td width="100">
		 	<input type="checkbox" onclick="checkAll(this.checked,'chgnews')"/>管理已审
		 	</td><td width="100">
		 	<input type="checkbox" onclick="checkAll(this.checked,'modifync')"/>管理未审
		 	</td></tr>
			</thead>
			<tbody>
			<tr align="center"><td align="left">
			<img src="pic/admin_tree_minusmiddle.gif" alt=""/> 网站首页
			</td><td>
	
			</td><td>
	
			</td><td>
			<input type="checkbox" name="setTop" value="0"/>
			</td><td>
	
			</td><td>
	
			</td><td>
	
			</td></tr>
				<asp:Repeater id="rpSorts" runat="server" >
				<ItemTemplate>
					<%# ((bool)Eval("canadd") ? rowFull : rowName).Replace("#name#", Eval("class").ToString()).Replace("#id#",Eval("classid").ToString())%>
				</ItemTemplate>
				</asp:Repeater>
			</tbody>
		 	</table>
		 </td></tr>
		 <tr><td>
		<form method="post" id="myForm" runat="server">
			 <div align="center">
			<input type="hidden" name="id" value="<%=Request.QueryString["id"]%>"/>
			<input type="hidden" id="uPower" runat="server"/>
			<input type="hidden" id="sPower" runat="server"/>
			 <asp:Button id="submit" onclick="Submit_OnClick" text="修改" runat="server"/>
			</div>
		 </form>
		 </td></tr>
		 </table>
		 <script type="text/javascript">
		 	CheckUPower();
		 	setTimeout("CheckSPower();",1000);
		 </script>
	</div>
	</div>
	<div class="bl"></div>
	<div class="br"></div>
	<div class="bm"></div>
	</div>

</asp:Content>