<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
<script type="Text/Javascript" language="JavaScript">
var last;
function add_main(key)
{
    var sysm = new Object;
          sysm[0] = new Array();
        sysm[0][0] = '问答首页';
        sysm[0][1] = '{k_siteinfo(1)}';
          sysm[1] = new Array();
        sysm[1][0] = '问题分类';
        sysm[1][1] = 'class.asp';
          sysm[2] = new Array();
        sysm[2][0] = '问题排行榜';
        sysm[2][1] = 'list.asp';
          sysm[3] = new Array();
        sysm[3][0] = '用户榜';
        sysm[3][1] = 'user.asp';
          sysm[4] = new Array();
        sysm[4][0] = '专家团';
        sysm[4][1] = 'zhuan.asp';
          sysm[5] = new Array();
        sysm[5][0] = '登录';
        sysm[5][1] = 'user/login.asp';
          sysm[6] = new Array();
        sysm[6][0] = '注册';
        sysm[6][1] = 'user/reg.asp';
		  sysm[7] = new Array();
        sysm[7][0] = '欢迎你：{k_Request.Cookies("Musername")}';
        sysm[7][1] = '';
          sysm[8] = new Array();
        sysm[8][0] = '退出';
        sysm[8][1] = 'user/loginout.asp';
          sysm[9] = new Array();
        sysm[9][0] = '个人中心';
        sysm[9][1] = 'user/userinfo.asp?id={k_Request.Cookies("Muser")}';
          sysm[10] = new Array();
        sysm[10][0] = '-';
        sysm[10][1] = '-';
          sysm[11] = new Array();
        sysm[11][0] = '关于我们';
        sysm[11][1] = 'aboutus.asp';
          sysm[12] = new Array();
        sysm[12][0] = '免责声明';
        sysm[12][1] = 'mianze.asp';
          sysm[13] = new Array();
        sysm[13][0] = '联系方式';
        sysm[13][1] = 'contact.asp';
          sysm[14] = new Array();
        sysm[14][0] = '快问知道';
        sysm[14][1] = 'http://www.kuaishow.com';
          sysm[15] = new Array();
        sysm[15][0] = 'Xhtml';
        sysm[15][1] = 'http://validator.w3.org/check/referer';
          sysm[16] = new Array();
        sysm[16][0] = 'Css';
        sysm[16][1] = 'http://jigsaw.w3.org/css-validator/validator-uri.html';
        if (key != '-')
    {
        if(sysm[key][0] != '-')
        {
            document.getElementById('NavName').value = sysm[key][0];
            document.getElementById('NavUrl').value = sysm[key][1];
            last = document.getElementById('menulist').selectedIndex;
			if(key>10)
			{
			document.getElementById('Type').selectedIndex=1;
			}
			else
			{
			document.getElementById('Type').selectedIndex=0;
			}
        }
        else
        {
            if(last < document.getElementById('menulist').selectedIndex)
            {
                document.getElementById('menulist').selectedIndex ++;
            }
            else
            {
                document.getElementById('menulist').selectedIndex --;
            }
            last = document.getElementById('menulist').selectedIndex;
            document.getElementById('NavName').value = sysm[last-1][0];
            document.getElementById('NavUrl').value = sysm[last-1][1];
			if(key>10)
			{
			document.getElementById('Type').selectedIndex=1;
			}
			else
			{
			document.getElementById('Type').selectedIndex=0;
			}
        }
    }
    else
    {
        last = document.getElementById('menulist').selectedIndex = 1;
        document.getElementById('NavName').value = sysm[last-1][0];
        document.getElementById('NavUrl').value = sysm[last-1][1];
		document.getElementById('NavUrl').value = sysm[last-1][1];
			if(key>10)
			{
			document.getElementById('Type').selectedIndex=1;
			}
			else
			{
			document.getElementById('Type').selectedIndex=0;
			}
    }
}

function chkform()
{
	if (document.frm.NavName.value==""||document.frm.NavName.value=="请填写导航文字")
	{
	document.frm.NavName.value="请填写导航文字";
	document.frm.NavName.focus();
	return false;
	}
//	if (document.frm.NavUrl.value==""||document.frm.NavUrl.value=="请填写链接地址")
//	{
//	document.frm.NavUrl.value="请填写链接地址";
//	document.frm.NavUrl.focus();
//	return false;
//	}
}
</script>
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
Call chkFlag(19)
dim act
act=Trim(Request.QueryString("act"))
opendb
Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	set AskD.myConn =conn
	AskD.myPredb =predb
select case act
  case "add","modi"
     Call meun()
  case "save"
     Call savep()
  case "del"
     Call del()
  case else
     Call Main()
end select
set AskD.myConn =Nothing
Set AskD=Nothing
closedb

sub savep()
   dim NavName,NavUrl,Pai,Show,NewWin,Type1,id,show2
   id=Trim(Request.QueryString("id"))
   NavName=Trim(Request.Form("NavName"))
   NavUrl=Trim(Request.Form("NavUrl"))
   Pai=Trim(Request.Form("Pai"))
   Show=Trim(Request.Form("Show"))
   NewWin=Trim(Request.Form("NewWin"))
   Type1=Trim(Request.Form("Type"))
   show2=Trim(Request.Form("show2"))
   if id="" then
   conn.execute("insert into "&predb&"Navigation(NavName,NavUrl,Pai,Show,NewWin,Type,show2) values('"&NavName&"','"&NavUrl&"',"&Pai&","&Show&","&NewWin&","&Type1&","&show2&")")
   
   Call SendMsg("恭喜，添加导航成功！")
   else
   conn.execute("update "&predb&"Navigation set NavName='"&NavName&"',NavUrl='"&NavUrl&"',Pai="&Pai&",Show="&Show&",NewWin="&NewWin&",Type="&Type1&",show2="&show2&" where id="&id)
   
   Call SendMsg("恭喜，修改导航成功！")
   end if
	AskD.DoDaohangXml()
   Response.Write("<script>setTimeout(""location.href='?';"",2000);</script>")
end sub

sub del()
  dim id
  id=Trim(Request.QueryString("id"))
  conn.execute("delete from "&predb&"Navigation where id="&id)
  
  Call SendMsg("恭喜，删除导航成功！")
  CALL AskD.DoDaohangXml()
  Response.Write("<script>setTimeout(""location.href='?';"",2000);</script>")
end sub

sub meun()
dim id,rs,NavName,NavUrl,Pai,Show,NewWin,Type1,show2
id=Trim(Request.QueryString("id"))
if id<>"" then
   set rs=conn.execute("select * from "&predb&"Navigation where id="&id)
   NavName=rs("NavName")
   NavUrl=rs("NavUrl")
   Pai=rs("Pai")
   Show=rs("Show")
   NewWin=rs("NewWin")
   Type1=rs("Type")
   show2=rs("show2")
   set rs=nothing
end if
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="2" align="left">网站导航<% If id="" Then %>添加<% Else %>修改<% End If %></th>
  </tr>
  <form action="?act=save&id=<%= id %>" name="frm" method="post" onSubmit="return chkform();">
  <tr>
    <td width="23%" align="right" class="TableRow1">系统内容：</td>
    <td width="77%" class="TableRow1">
    <select name="menulist" id="menulist" onChange="add_main(this.value);">
      <option value="-">---</option>
      <option value="0">问答首页</option>
      <option value="1">问题分类</option>
      <option value="2">问题排行榜</option>
      <option value="3">用户榜</option>
      <option value="4">专家团</option>
      <option value="5">登录</option>
      <option value="6">注册</option>
      <option value="7">欢迎您：</option>
      <option value="8">退出</option>
      <option value="9">个人中心</option>
      <option value="10">---</option>
      <option value="11">关于我们</option>
      <option value="12">免责声明</option>
      <option value="13">联系方式</option>
      <option value="14">快问知道</option>
      <option value="15">Xhtml</option>
      <option value="16">Css</option>
    </select>    </td>
  </tr>
  <tr>
    <td align="right" class="TableRow2">导航文字：</td>
    <td class="TableRow2"><input name="NavName" type="text" id="NavName" size="46" onClick="if(this.value=='请填写导航文字'){this.value=''}" value="<%= server.HTMLEncode(NavName) %>">
    &nbsp; <font color="#999999">支持HTML</font></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1">链接地址：</td>
    <td class="TableRow1"><input name="NavUrl" type="text" id="NavUrl" size="46" onClick="if(this.value=='请填写链接地址'){this.value=''}" value="<%= server.HTMLEncode(NavUrl) %>"></td>
  </tr>
  <tr>
    <td align="right" class="TableRow2">排序：</td>
    <td class="TableRow2"><input name="Pai" type="text" id="Pai"<% If pai>0 Then Response.Write(" value="""&pai&"""") Else Response.Write(" value=""0""") End If %> size="4" onKeyUp="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1">是否显示：</td>
    <td class="TableRow1">
    <select name="Show" id="Show">
      <option value="1"<% If Show=1 Then %> selected<% End If %>>是</option>
      <option value="2"<% If Show=2 Then %> selected<% End If %>>否</option>
    </select>    </td>
  </tr>
  <tr>
    <td align="right" class="TableRow2">是否新窗口：</td>
    <td class="TableRow2"><select name="NewWin" id="NewWin">
      <option value="1"<% If NewWin=1 Then %> selected<% End If %>>是</option>
      <option value="2"<% If NewWin=2 Then %> selected<% End If %>>否</option>
    </select></td>
  </tr>
  <tr>
    <td align="right" class="TableRow1">位置：</td>
    <td class="TableRow1"><select name="Type" id="Type">
      <option value="1"<% If Type1=1 Then %> selected<% End If %>>顶部</option>
      <option value="2"<% If Type1=2 Then %> selected<% End If %>>底部</option>
        </select></td>
  </tr>
  <tr>
    <td align="right" class="TableRow2">显示方式：</td>
    <td class="TableRow2">
      <select name="show2">
        <option value="0"<% If show2=0 Then %> selected<% End If %>> 总是显示 </option>
        <option value="1"<% If show2=1 Then %> selected<% End If %> style="background-color: #009900;color:#FFFFFF"> 登录前显示 </option>
        <option value="2"<% If show2=2 Then %> selected<% End If %> style="background-color: #FF6600;color:#FFFFFF"> 登录后显示 </option>
      </select>
    </td>
  </tr>
  <tr>
    <td class="TableRow1">&nbsp;</td>
    <td class="TableRow1"><input name="button2" type="submit" id="button2" value="确认<% If id="" Then %>添加<% Else %>修改<% End If %>">
     &nbsp; <input type="button" name="button3" id="button3" value="放弃<% If id="" Then %>添加<% Else %>修改<% End If %>" onClick="history.go(-1)"></td>
  </tr>
  </form>
</table>
<%
end sub

Sub Main()
dim rs,i,c
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
  <tr>
	<th height="25" colspan="8" align="left">网站导航设置</th>
  </tr>
  <tr>
    <td width="14%" class="TableRow1" align="center"><strong>导航文字</strong></td>
    <td width="25%" class="TableRow1" align="center"><strong>链接地址</strong></td>
    <td width="9%" align="center" class="TableRow1"><strong>新窗口</strong></td>
    <td width="9%" align="center" class="TableRow1"><strong>显示</strong></td>
    <td width="10%" align="center" class="TableRow1"><strong>位置</strong></td>
    <td width="8%" align="center" class="TableRow1"><strong>排序</strong></td>
    <td align="center" class="TableRow1"><strong>显示方式</strong></td>
    <td width="15%" class="TableRow1" align="center"><strong>操作</strong></td>
  </tr>
<%
set rs=conn.execute("select * from "&predb&"Navigation where type=1 order by pai asc,id asc")
do while not rs.eof
i=i+1
if i mod 2=0 then
   c=1
else
   c=2
end if
%>
  <tr>
    <td class="TableRow<%= c %>"><%= rs("NavName") %></td>
    <td class="TableRow<%= c %>"><%= server.HTMLEncode(rs("NavUrl")) %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("NewWin")=1 Then %><img src="Images/yes.gif" width="14" height="14"><% Else %><img src="Images/no.gif" width="14" height="14"><% End If %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("Show")=1 Then %><img src="Images/yes.gif" width="14" height="14"><% Else %><img src="Images/no.gif" width="14" height="14"><% End If %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("type")=1 Then %>顶部<% Else %>底部<% End If %></td>
    <td class="TableRow<%= c %>" align="center"><%= rs("pai") %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("show2")=0 Then %>总显示<% ElseIf rs("show2")=1 Then %><font style="background-color:#009900; color:#FFFFFF; padding-top:2px;">登录前</font><% Else %><font style="background-color:#FF6600; color:#FFFFFF; padding-top:2px;">登录后</font><% End If %></td>
    <td class="TableRow<%= c %>" align="center"><a href="?act=del&id=<%= rs("id") %>" onClick="return confirm('请确认您的操作？');">删除</a>&nbsp; <a href="?act=modi&id=<%= rs("id") %>">修改</a></td>
  </tr>
<%
rs.movenext
loop
set rs=nothing
%>
  <tr>
    <td colspan="8" class="TableRow1"><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><font color="#008800">&uarr;顶部导航</font></td>
        <td align="right"><font color="#008800">底部导航&darr;</font></td>
      </tr>
    </table></td>
  </tr>
<%
i=0
set rs=conn.execute("select * from "&predb&"Navigation where type=2 order by pai asc,id asc")
do while not rs.eof
i=i+1
if i mod 2=0 then
   c=1
else
   c=2
end if
%>
  <tr>
    <td class="TableRow<%= c %>"><%= rs("NavName") %></td>
    <td class="TableRow<%= c %>"><%= server.HTMLEncode(rs("NavUrl")) %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("NewWin")=1 Then %><img src="Images/yes.gif" width="14" height="14"><% Else %><img src="Images/no.gif" width="14" height="14"><% End If %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("Show")=1 Then %><img src="Images/yes.gif" width="14" height="14"><% Else %><img src="Images/no.gif" width="14" height="14"><% End If %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("type")=1 Then %>顶部<% Else %>底部<% End If %></td>
    <td class="TableRow<%= c %>" align="center"><%= rs("pai") %></td>
    <td class="TableRow<%= c %>" align="center"><% If rs("show2")=0 Then %>总显示<% ElseIf rs("show2")=1 Then %><font style="background-color:#009900; color:#FFFFFF; padding-top:2px;">登录前</font><% Else %><font style="background-color:#FF6600; color:#FFFFFF; padding-top:2px;">登录后</font><% End If %></td>
    <td class="TableRow<%= c %>" align="center"><a href="?act=del&id=<%= rs("id") %>" onClick="return confirm('请确认您的操作？');">删除</a>&nbsp; <a href="?act=modi&id=<%= rs("id") %>">修改</a></td>
  </tr>
<%
rs.movenext
loop
set rs=nothing
%>
  <tr>
    <td colspan="8" class="TableRow2"><input type="button" name="button" id="button" value="添加新导航" onClick="location.href='?act=add'"></td>
  </tr>
</table>
<% End Sub %>
<br>
</body>
</html>
