<!--#include file="../common/conn.asp"-->
<%
'检查用户权限
call checkuser(GetQueryString("WindowName"))

%>
<%
'读取留言本的属性，以确定显示那个字段
strCurrMenu=GetVariable("mnid")
isDW=GetKey("g_dw",WebUserID,"guestbook_" & strCurrMenu )
isTel=GetKey("g_tel",WebUserID,"guestbook_" & strCurrMenu )
isEmail=GetKey("g_email",WebUserID,"guestbook_" & strCurrMenu )
isAdrr=GetKey("g_adrr",WebUserID,"guestbook_" & strCurrMenu )
isOICQ=GetKey("g_oicq",WebUserID,"guestbook_" & strCurrMenu )
isIP=GetKey("g_ip",WebUserID,"guestbook_" & strCurrMenu )							
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=GetQueryString("WindowName")%></title>
<STYLE type="text/css">
td			{font-size:9pt;line-height:140%}
A:active	{COLOR: #FFFFFF;}
A:visited	{COLOR: #333333; TEXT-DECORATION: none}
A:hover		{COLOR: #000033;TEXT-DECORATION: none}
A:link		{COLOR: #333333; TEXT-DECORATION: none}
</STYLE>
<script language="JavaScript">
function fhmsg(intID){
	objDiv=eval("document.all.hfMsg" + intID)
	if (objDiv.style.display=='none'){
		objDiv.style.display=''
	}
	else
	{
	objDiv.style.display='none'
	}
	objDiv.style.display='none';
	objDiv=eval("document.all.hfForm" + intID)
	if (objDiv.style.display=='none'){
		objDiv.style.display=''
	}
	else
	{
	objDiv.style.display='none'
	}

}
</script>
</head>
<%
'从这开始读数据
strSQL="Select * From web_guestbook Where mn_id=" & strCurrMenu & " Order By id Desc"
rs.open strSQL,conn,1,1
'分页显示初始化
page=GetVariable("page")
if page="" then
	page=1
else
	page=Cint(page)
end if

Section=GetVariable("section")
if Section="" then
	Section=1
else
	Section=Cint(Section)
end if
'变量赋值
intPageSize=15		'每页显示记录数
intSectionSize=5		'多少页为一段，像GOOGLE一样
PrevSectionText="<FONT face=webdings>7</FONT>"		'上一段的链接文字
NextSectionText="<FONT face=webdings>8</FONT>"		'下一段的链接文字
PrevPageText="<FONT face=webdings>3</FONT>"			'上页的链接文字	
NextPageText="<FONT face=webdings>4</FONT>"			'下页的链接文字

strPageUrl="?mnid=" & GetVariable("mnid") & "&WindowName=" & GetQueryString("WindowName")

rs.pagesize=intPageSize
intCount=rs.RecordCount 
intPageCount=rs.pagecount
intSectionCount=(intPageCount - 1) \ intSectionSize + 1
if intCount>0 then
	rs.AbsolutePage=page  
end if
%>
<body leftmargin="0" topmargin="0" BodyBegin>
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#336600">
  <tr> 
    <td width="100%" bgcolor="#669900"><strong><font color="#FFFFFF">留言板管理</font></strong></td>
  </tr>
  <%
 '循环输出
 for i=1 to intPageSize
 	if rs.eof then exit for
	if i mod 2=0 then
		strColor="#eeeeee"
	else
		strColor="#f9f9f9"
	end if
 %>
  <tr align="center" bgcolor="#F9F9F9"> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="3">
        <tr align="center"> 
          <td colspan="2"> <hr width="95%" style="color:#669900"></td>
        </tr>
        <tr> 
          <td width="16%" align="right"><strong>姓　名：</strong></td>
          <td width="84%"><%=trim(rs("g_Name"))%></td>
        </tr>
       <%if isDW<>"none" then%>
        <tr id="g_dw"> 
          <td align="right"><strong>单　位：</strong></td>
          <td><%=trim(rs("g_dw"))%></td>
        </tr>
		<%End if%>
       <%if isEmail<>"none" then%>
        <tr id="g_email"> 
          <td align="right"><strong>电子邮件：</strong></td>
          <td><%=trim(rs("g_email"))%></td>
        </tr>
		<%End if%>
       <%if isAdrr<>"none" And isAdrr<>"Null" then%>
        <tr id="g_adrr"> 
          <td align="right"><strong>地　址：</strong></td>
          <td><%=trim(rs("g_addr"))%></td>
        </tr>
		<%End if%>
       <%if isTel<>"none" then%>
        <tr id="g_tel"> 
          <td align="right"><strong>电　话：</strong></td>
          <td><%=trim(rs("g_tel"))%></td>
        </tr>
		<%End if%>
       <%if isOICQ<>"none" And isOICQ<>"Null" then%>
        <tr id="g_oicq"> 
          <td align="right"><strong>OICQ：</strong></td>
          <td><%=trim(rs("g_oicq"))%></td>
        </tr>
		<%End if%>
       <%if isIP<>"none" then%>
        <tr id="g_ip"> 
          <td align="right"><strong>IP地址：</strong></td>
          <td><%=trim(rs("g_ip"))%></td>
        </tr>
		<%End if%>
        <tr> 
          <td align="right"><strong>留言时间：</strong></td>
          <td><%=year(rs("g_time")) & "年" & month(rs("g_time")) & "月" & day(rs("g_time")) & "日 " & hour(rs("g_time")) & "时" &  minute(rs("g_time")) & "分"%></td>
        </tr>
        <tr> 
          <td align="right"><strong>留　言：</strong></td>
          <td><%=trim(rs("g_msg"))%></td>
        </tr>
        <tr> 
          <td align="right"><strong>回复内容：</strong></td>
          <td><div id="hfMsg<%=rs("ID")%>" style="display:''"> 
              <%
		  if trim(rs("g_hfmsg"))<>"" then
		  	response.Write(trim(rs("g_hfmsg")))
		  else
		  	response.Write("[<a href=javascript:; onclick=fhmsg(" & rs("ID")& ")>未回复</a>]")
		  end if
		  %>
            </div>
            <Div ID="hfForm<%=rs("ID")%>" style="display:none"> 
              <form action="hfmsg.asp?id=<%=rs("ID")%>&WindowName=<%=GetQueryString("WindowName")%>" method="post" name="form<%=rs("ID")%>" target="BackFrame">
                <textarea name="hfmsg" cols="40" rows="5" id="hfmsg"><%=replace(trim(rs("g_hfmsg")) & "","<br>",VBcrlf)%></textarea>
                <br>
                <input type="submit" name="Submit" value="保存回复">
                <input type="reset" name="Submit2" value="重　置">
              </form>
            </Div></td>
        </tr>
        <tr> 
          <td height="40" colspan="2" align="center">[<a href="javascript:;" onclick="fhmsg(<%=rs("ID")%>)">回复留言</a>]　 
            [<a href="delemsg.asp?id=<%=rs("ID")%>&WindowName=<%=GetQueryString("WindowName")%>" target="BackFrame">删除留言</a>]</td>
        </tr>
        <tr align="center"> 
          <td colspan="2"> <hr width="95%" style="color:#669900"></td>
        </tr>
      </table> </td>
  </tr>
  <%
 	 rs.movenext
  next
  %>
  <tr> 
    <td bgcolor="#669900"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td align="right"> <font color="#FFFFFF">共有<%=intCount%>记录，分<%=intPageCount%>页，当前页<%=Page%>，每页显示<%=intPageSize%>条记录 
            <%
			'计算每一段的开始页
			intStarPage=(Section-2) * intSectionSize + 1
			'前一段
			if Section<=1 then
				response.Write(PrevSectionText & " ")
			else
				response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section-1 & "'>" & PrevSectionText & "</a> ")
			end if 
			
			'显示页码列表
			response.Write("第")
			intStarPage=(Section-1) * intSectionSize + 1
		    for p=intStarPage to intStarPage + intSectionSize - 1
				if p > intPageCount then exit for
				if p=page then
		    		response.Write("<strong>[" & p & "]</strong> ")
				else
		    		response.Write("<a href='" & strPageUrl & "&page=" & p & "&section=" & Section & "'>[" & p & "]</a> ")
				end if	
		    next
			response.Write("页")
			'后一段
			intStarPage=(Section) * intSectionSize + 1
			if Section>=intSectionCount then
				response.Write(" " & NextSectionText)
			else
				response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage & "&section=" & Section+1 & "'>" & NextSectionText & "</a> ")
			end if 
		  %>
            <select name="page" size="1" onchange="window.location='<%=strPageUrl & "&section="%>' + (Math.floor((parseInt(this.value)-1)/<%=intSectionSize%>)+1) + '<%="&page="%>' + this.value">
              <option value="<%=page%>" selected>第<%=page%>页</option>
              <%
							for i=1 to rs.pagecount
					%>
              <option value="<%=i%>" >第<%=i%>页</option>
              <%
							next
					 %>
            </select>
            </font> 　 </td>
        </tr>
      </table></td>
  </tr>
</table>
<iframe name="BackFrame" width="0" height="0" src="about:blank"></iframe>
</body>
</html>
