<!--#include file="conn.asp"-->
<%
if GetVariable("deleid")<>"" then
	'删除文件
	strsql="select mn_href From menu Where id=" & GetVariable("deleid")&" or mn_parent="&GetVariable("deleid")
	rs.open strsql,conn,1,1
	for i=1 to rs.recordcount
		strUserName=Session("UserName")
		HomeFolderName = "home/" & strUserName
		HomeFolderName = Server.MapPath( HomeFolderName )
		Set fs = Server.CreateObject( Const_ScriptFileSystem )
		DeleteFile=HomeFolderName & "\" & rs(0)
		if fs.FileExists(DeleteFile) then
			fs.DeleteFile DeleteFile,true
		end if
		set fs=nothing
		rs.movenext
	next
	rs.close
	conn.execute "Delete From menu Where id=" & GetVariable("deleid")&" or mn_parent="&GetVariable("deleid"),0,1
end if

if GetVariable("action")="save" then
	strAllIndex=GetFormVariable("allindex")
	IndexList=Split(strAllIndex,",")
	strallmenu=GetFormVariable("allmenu")
	MenuList=Split(strallmenu,",")
	iCount=UBound(IndexList)-1
	for i=0 to iCount
		strSQL="Update menu Set mn_index=" & IndexList(i) & " Where id=" & MenuList(i)
		conn.execute strSQL,0,1
	next
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>电子商务自助建站--您理想的助手</title>
<link href="common/styleMain.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="common/JS_CheckForm.js"></script>
<script language="JavaScript">
//检查数据有效性
function checkform(theform){
	theform.allindex.value="";
	theform.allmenu.value="";
	for(i=0;i<theform.txtIndex.length;i++){
		theform.allindex.value+=theform.txtIndex[i].value + ",";
		theform.allmenu.value+=theform.menuid[i].value + ",";
		/*
		if(theform.txtIndex[i].value!=i.toString()){
			alert("栏目序号必须是连续的，且从0开始， 请重新设值！　　");
			return false;
		}
		*/
	}
}

//应用设置
function AppMenu(){
	form1.chkmenu.value="";
	//检查要应用设置的菜单
	for (i=0;i<form1.chkMenu.length;i++){
		if(form1.chkMenu[i].checked){
			form1.chkmenu.value+=form1.chkMenu[i].value + ","
		}
	}
	form1.chkmenu.value="(" + form1.chkmenu.value + "0)";
	//alert(form1.chkmenu.value);
	window.open('AppSetting.asp?c=1&js=1&menu=' + form1.chkmenu.value)
}
</script>
</head>
<body leftmargin="0" topmargin="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td height="0" align="center">
		  <!--#include file="common/top.asp"-->
          </td>
        </tr>
        <tr> 
          <td height="100%" align="center" valign="top">
<TABLE class=table002 cellSpacing=0 cellPadding=0 border=0>
              <TBODY>
                <TR> 
                  <!--左边开始-->
                  <TD vAlign=top align=right width="20%">
					  <!--#include file="common/left.asp"-->
				  </TD>
                  <!--左边结束-->
                  <TD width="2%" background="images/rowline.gif">&nbsp;</TD>
                  <!--右边开始-->
                  <TD vAlign=top align=middle width="78%">
<%
strSQL="Select * From menu Where m_id=" & trim(Session("UserID")) & " And mn_parent=0 Order By mn_index"
rs.open strSQL,conn,1,1
intCount=rs.recordcount
%>

				  
				  <form name="form1" method="post" action="?action=save" onSubmit="return checkform(this)">
                      <TABLE width="100%" height="100%" border=0 cellPadding=6 cellSpacing=0>
                        <TBODY>
                          <TR> 
                            <TD vAlign=top align=left bgColor=#ffffff><B>网站栏目设置</B> 
                              <input name="allindex" type="hidden" id="allindex2">
                              <input name="allmenu" type="hidden" id="allmenu">
                              <input name="chkMenu" type="checkbox" id="chkMenu" style="display:none">
                              <input name="chkmenu" type="hidden" id="chkmenu">
                              <BR> 
                              <HR SIZE=1> 
                              <table width="100%" border="1" cellpadding="1" cellspacing="1" bgcolor="#bad2f0">
                                <tr> 
                                  <td bgcolor="#5f8ac5"><font color="#FFFFFF">□ 
                                    一级栏目 </font></td>
                                </tr>
                                <tr> 
                                  <td valign="top" bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="2">
                                      <tr> 
                                        <td><table width="100%" border="0" cellpadding="0" cellspacing="1">
                                            <tr> 
                                              <td width="5%" height="26" align="center"><strong>序号</strong></td>
                                              <td width="20%" height="26" align="center"><strong>名称</strong></td>
                                              <td width="8%" height="26" align="center"><strong>状态</strong></td>
                                              <td width="10%" height="26" align="center">&nbsp;</td>
                                              <td width="10%" height="26" align="center">&nbsp;</td>
                                              <td height="26" colspan="3" align="center"> 
                                                <button onClick="location='Admin_MenuAdd.asp?pid=0&index=<%=intCount%>'"> 
                                                新 建 栏 目 </button></td>
                                            </tr>
                                            <%
											for i=1 to intCount
												if i mod 2 = 0 then
													strColor="#FFFFFF"
												else
													strColor="#F4F4F4"
												end if
											%>
                                            <tr bgcolor="<%=strColor%>"> 
                                              <td height="26" align="center"> 
                                                <input name="txtIndex" type="text" value="<%=trim(rs("mn_index"))%>" size="2" maxlength="2"> 
                                                <input name="menuid" type="hidden" id="menuid" value="<%=trim(rs("id"))%>"> 
                                              </td>
                                              <td height="26"><a href="<%if rs("tm_id")=0 and instr(trim(rs("mn_Href")),":")>0 then response.Write(trim(rs("mn_Href"))) else response.Write(HomePage & trim(rs("mn_Href"))) end if%>" target="_blank" class="<%=trim(rs("mn_class"))%>"><strong> 
                                                <input name="chkMenu" type="checkbox" id="chkMenu" value="<%=trim(rs("id"))%>" checked>
                                                <%=trim(rs("mn_name"))%></strong></a></td>
                                              <td height="26" align="center"> 
                                                <%if rs("mn_enable")>0 then%> <font color="#FF0000">√启用</font> 
                                                <%else%> <font color="#CC9900">禁用</font> 
                                                <%end if%> </td>
                                              <td height="26" align="center"> 
                                                <INPUT type=button value="删除" name=Submit3 onClick="location='?deleid=<%=trim(rs("id"))%>&file=<%=trim(rs("mn_Href"))%>'"></td>
                                              <td height="26" align="center"> 
                                                <INPUT type=button value="属性" name=Submit32 onClick="location='Admin_MenuAttrib.asp?id=<%=trim(rs("id"))%>&url=SetMenu'"></td>
											<%
											strSQL="Select * From v_menu Where tm_id=" & rs("tm_id") & ""
											set rslamu = Server.CreateObject("ADODB.Recordset")
											rslamu.open strSQL,conn,1,1
											if not rslamu.eof then 
											%>
											  <td height="26" align="center"> 
                                                <INPUT type=button value="编辑内容" name=Submit322 onClick="location='Admin_EditMode.asp?id=<%=trim(rs("id"))%>&readonly=<%=trim(rslamu("l_readonly"))%>&title=<%=trim(rs("mn_name"))%>&File=<%=trim(rs("mn_href"))%>'"></td>
                                              <td height="26" align="center"> 
                                                <%
											  strHaveSub=trim(rslamu("l_havesub"))
											  strDisabled=""
											  if strHaveSub="NO" then
											  	strDisabled="Disabled"
											  end if
											  %> <INPUT type=button value="子栏目" <%=strDisabled%> name=Submit3222 onClick="location='Admin_SubMenu.asp?pid=<%=trim(rs("id"))%>&menu=<%=trim(rs("mn_name"))%>'">
                                              </td>
											<%else%>
											  <td height="26" align="center"> 
                                                <INPUT type=button value="编辑内容" name=Submit322 Disabled></td>
                                              <td height="26" align="center"> 
                                               <INPUT type=button value="子栏目" Disabled name=Submit3222>
                                              </td>
											<%
											end if
											rslamu.close
											set rslamu=nothing
											%>
                                            </tr>
                                            <%
												rs.movenext
											next
											rs.close
											%>
                                          </table></td>
                                      </tr>
                                      <tr> 
                                        <td height="50" align="center"><INPUT type=submit value=" 保存 " name=Submit>
                                          <INPUT type=button value=" 应用 " name=Submit4 onClick="AppMenu()">
                                          <input type=button value=" 上一步 " name=Submit22 onClick="location='Admin_Templet.asp'">
                                          <input type=button value=" 下一步 " name=Submit2 onClick="location='Admin_Website.asp'"></td>
                                      </tr>
                                    </table></td>
                                </tr>
                              </table></TD>
                          </TR>
                        </TBODY>
                      </TABLE>
                    </form></TD>
                </TR>
              </TBODY>
            </TABLE></td>
        </tr>
        <tr> 
          <td height="0" align="center">
		  <!--#include file="common/bottom.asp"-->
		  </td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
