<%@ codepage ="936" %>
<%charset="gb2312"%>
<%Session.CodePage=936%>
<!--#include file="Admin.asp"-->
<!--#include file="Conn.asp"-->
<%
BigClassID = request("BigClassID")
If BigClassID="" Then BigClassID=0
If request("abc")="order" Then
	orders = request("orders")
	set rs=server.CreateObject("adodb.recordset")
	rs.open "Select BigClassID,orders From NewsBigClass order by orders desc",conn,1,1
	total = rs.recordcount
	prevID=0
	times=0
	Do While Not rs.eof
		If (orders="up" And prevID > 0 And CInt(BigClassID) = rs("BigClassid")) Or (orders="down" And prevID = CInt(BigClassID) And times=0) Then   '符合条件
			conn.execute("update NewsBigClass set orders=" & total & " where BigClassID=" & prevID & "")
			conn.execute("update NewsBigClass set orders=" & total+1 & " where BigClassID=" & rs("BigClassid") & "")
			prevID = prevID
			times=1
		Else
			conn.execute("update NewsBigClass set orders=" & total & " where BigClassID=" & rs("BigClassid") & "")
			prevID = rs("BigClassid")
		End if
		rs.movenext
		total=total-1
	Loop
	rs.close
	Set rs=nothing
	'response.redirect "News_ClassManage.asp"
End if
dim sql,rsBigClass,rsSmallClass,ErrMsg
set rsBigClass=server.CreateObject("adodb.recordset")
rsBigClass.open "Select * From NewsBigClass order by orders desc,BigClassid asc",conn,1,1
If Not (rsBigClass.bof And rsBigClass.eof) Then
	total = rsBigClass.recordcount
Else
	total = 0
End if
%>
<script language="JavaScript" type="text/JavaScript">
function checkBig()
{
  if (document.form1.BigClassName.value=="")
  {
    alert("大类名称不能为空！");
    document.form1.BigClassName.focus();
    return false;
  }
}
function checkSmall()
{
  if (document.form2.BigClassName.value=="")
  {
    alert("请先添加大类名称！");
	document.form1.BigClassName.focus();
	return false;
  }

  if (document.form2.SmallClassName.value=="")
  {
    alert("小类名称不能为空！");
	document.form2.SmallClassName.focus();
	return false;
  }
}
function ConfirmDelBig()
{
   if(confirm("确定要删除此大类吗？删除此大类同时将删除所包含的小类，并且不能恢复！"))
     return true;
   else
     return false;
	 
}

function ConfirmDelSmall()
{
   if(confirm("确定要删除此小类吗？一旦删除将不能恢复！"))
     return true;
   else
     return false;
	 
}
</script>

<SCRIPT language=javascript1.2>
var maxMenu=<%=total%>;
function showsubmenu(sid)
{
  var myFlag
  myFlag=form_left.myFlag.value
  whichEl = eval("submenu" + sid);
  try{
	  if (myFlag!="")
	  {
		  if (myFlag!=sid)
		  {
			eval("submenu" + myFlag + ".style.display=\"none\";");
		  }
	  }
	  if (whichEl.style.display == "none"){
		  eval("submenu" + sid + ".style.display=\"\";");
		  form_left.myFlag.value=sid
	  }else{
		  eval("submenu" + sid + ".style.display=\"none\";");
	  }
  }catch(e){}
}
function showAll(lx)
{
	for(i=0;i<maxMenu;i++)
	{
		if (lx==0)
			eval("submenu" + i + ".style.display=\"\";");
		else
			eval("submenu" + i + ".style.display=\"none\";");
	}
}
</SCRIPT>

<!-- #include file="Inc/Head.asp" -->
<form name="form_left">
<input type="hidden" name="myFlag">
<input type="hidden" name="closeFlag">
</form>
<SCRIPT language=javascript1.2>
form_left.myFlag.value="0";
form_left.closeFlag.value="have";
</SCRIPT>
<div align=center>
<TABLE class=tableBorder1 style="WIDTH: 100%" cellSpacing=0 cellPadding=3 
align=center border=0>
  <TBODY>
  <TR>
    <TD height=20></TD></TR></TBODY></TABLE>
<TABLE class=tableBorder cellSpacing=0 cellPadding=0 width="95%" align=center border=0>
	<tr> 
		<TH align=left height=23 class="tableHeaderText"><div align="center"><font color=white>频 道 类 别 设 置</font></div></TH>
	</tr>
	<tr> 
	  <td height="25" class=forumHeaderBackgroundAlternate>
	    <div align="center">管理选项：<a href="News_ClassAddBig.asp">添加频道大类</a>　　　<a href="javascript:;" onclick='showAll(0);'>展开小类</a> | <a href="javascript:;" onclick='showAll(1);'>收缩小类</a><br></div>
	  </td>
	</tr>
	<tr>  
	  <td>
      <table width="100%" border="0" cellSpacing=1 cellPadding=2  valign="top">
    <%
	jj=0
	do while not rsBigClass.eof
	%>
        <tr> 
          <td class=forumRow_hui width=222 height="30">
		    <img src="Image/tree_folder4.gif" width="15" height="15">
			&nbsp;<a href="javascript:;" onclick='showsubmenu(<%=jj%>);'  style="font-size:14px;font-weight:bold;"><%=rsBigClass("BigClassName")%></a>
		  </td>
		  <td class=forumRow_hui>
			&nbsp;
			<a href="News_ClassAddSmall.asp?BigClassID=<%=rsBigClass("BigClassID")%>"><img align=absmiddle src="image/child.png" style="width:16px;height:16px;" alt="添加子栏目" border=0/></a>&nbsp;
			<a href="News_Manage.asp?BigClassID=<%=rsBigClass("BigClassID")%>"><img align=absmiddle src="image/view.png" style="width:16px;height:16px;" alt="查看" border=0/></a>&nbsp;
            <a href="News_ClassModifyBig.asp?BigClassID=<%=rsBigClass("BigClassID")%>"><img align=absmiddle src="image/edit.png" style="width:16px;height:16px;" alt="修改" border=0/></a>&nbsp;
            <a href="News_ClassDelBig.asp?BigClassID=<%=rsBigClass("BigClassID")%>" onClick="return ConfirmDelBig();"><img align=absmiddle src="image/delete.png" style="width:16px;height:16px;" alt="删除" border=0/></a>&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="News_ClassManage.asp?abc=order&BigClassID=<%=rsBigClass("BigClassID")%>&orders=up"><img align=absmiddle src="image/up.png" style="width:16px;height:16px;" alt="上移" border=0/></a>&nbsp
			<a href="News_ClassManage.asp?abc=order&BigClassID=<%=rsBigClass("BigClassID")%>&orders=down"><img align=absmiddle src="image/down.png" style="width:16px;height:16px;" alt="下移" border=0/></a>
			&nbsp;&nbsp;&nbsp;&nbsp;
			排序值：<%=rsBigClass("orders")%>&nbsp;&nbsp;
			<%If rsBigClass("show")>0 then%>推荐值：<%=rsBigClass("show")%>&nbsp;&nbsp;<%End if%>
			<%If rsBigClass("target")=1 Then response.write "<font color=#990000>新窗口打开</font>"%>
		  </td>
        </tr>
    <%
	  set rsSmallClass=server.CreateObject("adodb.recordset")
	  rsSmallClass.open "Select * From NewsSmallClass Where BigClassID=" & rsBigClass("BigClassID") & " order by orders desc,SmallClassid asc",conn,1,1
	  if not(rsSmallClass.bof and rsSmallClass.eof) Then
		If jj>0 And rsSmallClass.recordcount>0 Then
			myshow=" style='display:none'"
		Else
			myshow=""
		End If
		If CLng(BigClassID)>0 Then myshow=" style='display:none'"
		If CLng(BigClassID)=rsSmallClass("BigClassID") Then myshow=""
	    response.write "<tr><td id=submenu" & jj & myshow & " colspan=2><table width='100%' border='0' cellSpacing=0 cellPadding=0  valign='top'><tr>"
		ii=0
		mybg="#FFFFFF"
		do while not rsSmallClass.eof
			If mybg="#FFFFFF" Then
				mybg="F1F3F5"
			Else
				mybg="#FFFFFF"
			End if
	%>
		  <td class=forumRow style="background:<%=mybg%>" width="30%" height="25" style="font-size:12px;border-bottom:1px solid #ddd;">
		    &nbsp;<img src="Image/tree_folder3.gif" width="15" height="15">&nbsp;<%=rsSmallClass("SmallClassName")%><%If rsSmallClass("show")>0 then%>&nbsp;<span title="推荐值" style="cursor:hand;color:red;font-weight:bold;">[<%=rsSmallClass("show")%>]</span><%End if%></td>
		  <td width="20%" class=forumRow style="background:<%=mybg%>;border-bottom:1px solid #ddd;">
			<a href="News_Manage.asp?BigClassID=<%=rsSmallClass("BigClassID")%>&SmallClassID=<%=rsSmallClass("SmallClassID")%>"><img align=absmiddle src="image/view.png" style="width:16px;height:16px;" alt="查看" border=0/></a> 
			<a href="News_ClassModifySmall.asp?SmallClassID=<%=rsSmallClass("SmallClassID")%>"><img align=absmiddle src="image/edit.png" style="width:16px;height:16px;" alt="修改" border=0/></a> 
			 <a href="News_ClassDelSmall.asp?SmallClassID=<%=rsSmallClass("SmallClassID")%>"><img align=absmiddle src="image/delete.png" style="width:16px;height:16px;" alt="删除" border=0/></a>
		  </td>
        <%
			rsSmallClass.movenext
			ii=ii+1
			If ii Mod 2=0 Then response.write "</tr><tr>"
		Loop
		response.write "</tr></table></td></tr>"
	  Else
		response.write "<tr style='display:none'><td id=submenu"&jj&" colspan=2></td></tr>"
	  end if
	  rsSmallClass.close
	  set rsSmallClass=nothing	
	  rsBigClass.movenext
	  jj=jj+1
	loop
%>
      </table> </td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
</div>

<%
rsBigClass.close
set rsBigClass=nothing
call CloseConn()
%>
