<!--#include file="head.asp"-->
<!-- 这里是主题 -->

<%
dim name,theitem,sql,rs,thepage,currentpage,pagename,totalpage,n,page
name=HtmlEncode(trim(request("keyword")))
theitem=HtmlEncode(trim(request("item")))
Set rs = Server.CreateObject("ADODB.Recordset")
  if name="" or name="请输入搜索关键字" then
    response.write "<SCRIPT language=JavaScript>alert('请输入搜索关键字！');"
	response.write "this.location.href='javascript:history.back()';</SCRIPT>"
   	response.end
  else
    if theitem="全部广告" then
    sql="select * from data where (title Like '%"& name &"%' or text Like '%"& name &"%' or type Like '%"& name &"%') and mark='yes' and stop >= date() order by top desc,money desc,time desc"
    rs.open sql,conn,1,1
    else
    sql="select * from data where (title Like '%"& name &"%' or text Like '%"& name &"%' or type Like '%"& name &"%') and type='"&theitem&"' and mark='yes' and stop >= date() order by top desc,money desc,time desc"
    rs.open sql,conn,1,1
    end if
  end if
if rs.eof then
	response.write "<SCRIPT language=JavaScript>alert('对不起，没有找到符合条件的广告内容！');"
	response.write "this.location.href='javascript:history.back()';</SCRIPT>"
	rs.close
	set rs=nothing
   	response.end
end if
thepage=request("pageid")
if isnumeric(thepage)=false then
response.write "<script>alert('参数错误，窗口关闭！');history.back();</script>"
response.end
end if
currentpage = cint(thepage)            
if currentpage <= 0 then currentpage=1       
const maxperpage=40                        
rs.Pagesize = maxperpage  
pagename="search.asp"                     
totalpage = rs.PageCount 
rs.absolutepage = currentpage 
n=rs.recordcount                    
page = PageSet(currentpage,totalpage,pagename)
%>


<TABLE WIDTH=778 BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
  <tr> 
    <td width="100%" height="24" colspan="7"> 
      <p align="center"><font style="font-size:12px"><b>您输入的搜索关键字：<font color="red"><%=name%></font>&nbsp;&nbsp;以下是搜索结果：</b></font></p></td>
  </tr>
  <TR> 
    <td width="100%" height="25" style="BORDER-RIGHT: #91b9dd 1px dotted; BORDER-TOP: #91b9dd 1px dotted; BORDER-LEFT: #91b9dd 1px dotted; BORDER-BOTTOM: #91b9dd 1px dotted" bgColor="#CAF046" colspan="7"> 
      <p align="center"><a href="default.asp"><font style="font-size:12px" color="#0000BF">全部广告</font></a>&nbsp;&nbsp;页次：<b><%=currentpage%>/ 
        <% =totalpage%>
        </b>&nbsp;&nbsp;每页<b><%=maxperpage%></b>条&nbsp;&nbsp;共刊登<b><%=n%></b>条广告&nbsp;&nbsp;&nbsp;&nbsp; 
        <% response.write page %>
    </td>
  </tr>
  <TR> 
    <%                
dim i,red_name                                                                               
i=0                                                                                                                                                                           
do while i < maxperpage and not rs.eof                                                     
red_name = replace(rs("text"),name,"<font color=#ff0000>"&name&"</font>")                                                                                                                            
%>
    <td width="25%" height="117"> 
      <table border="0" width="100%" cellpadding="1" cellspacing="2">
        <tr> 
          <td width="100%" height="24" align="center" bgcolor="#F9F168" style="BORDER-RIGHT: #dd91a5 1px dotted; BORDER-TOP: #dd91a5 1px dotted; BORDER-LEFT: #dd91a5 1px dotted; BORDER-BOTTOM: #dd91a5 1px dotted" <%if rs("bgcolor1")<>"" then%>bgcolor="<%=rs("bgcolor1")%>"<%else%>bgColor="#ffe8e8"<%end if%>> 
            <a href="show.asp?id=<%=rs("adid")%>" target="_blank"> 
            <% if rs("cu")="yes" then %>
            <b><font style="font-size:12px" <% if rs("color")<>"" then %>color="<%=rs("color")%>"<% end if %>><%=left(rs("title"),10)%></font></b> 
            <% else %>
            <font style="font-size:12px" <% if rs("color")<>"" then %>color="<%=rs("color")%>"<% end if %>><%=left(rs("title"),10)%></font> 
            <% end if %>
            </a> </td>
        </tr>
        <tr> 
          <script language=JavaScript>
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
function statusOut() {
self.status = '';
}
</script>
          <td width="100%" height="87" align="center" valign="top" style="BORDER-RIGHT: #dd91a5 1px dotted; BORDER-TOP: #dd91a5 1px dotted; BORDER-LEFT: #dd91a5 1px dotted; BORDER-BOTTOM: #dd91a5 1px dotted;cursor: hand" onclick=window.open("show.asp?id=<%=rs("adid")%>","_blank") onMouseOver="MM_displayStatusMsg('键连至 <%=rs("title")%>');return true;" onMouseOut=statusOut();> 
            <% if rs("ispic")<>"yes" then %>
            <% else %>
            <img src="adpic/<%=rs("pic")%>" border="0" width="100" height="80"> 
            <% end if %>
          </td>
        </tr>
      </table></td>
    <%                                      
i=i+1
if i mod 7=0 then  
response.write "</tr><tr>"        
end if
rs.movenext
loop  
if (n mod 7) <> 0 and not i mod maxperpage = 0 Then 
for i = 1 to (7 - (n mod 7))  
%>
    <%                                                
next                                                  
end if                                                                            
rs.close                                                   
set rs=nothing                                                 
conn.close                                                    
set conn=nothing                                 
%>
  </tr>
</table>


<%                                                                      
Function PageSet(currentpage,totalpage,pagename)                                                                                                  
if currentpage mod 10 = 0 then                                                                                                  
Sp = currentpage \ 10                                                                                                  
else                                                                                                  
Sp = currentpage \ 10 + 1                                                                                                  
end if                                                                                                  
Pagestart = (Sp-1)*10+1                                                                                                  
Pageend = Sp*10                                                                                                  
strSplit = "<a href="&pagename&"?keyword="&name&"&item="&theitem&"&pageid=1><font face=webdings title=第一页>9</font></a>&nbsp;"                                                                                                  
if Sp > 1 then strSplit = strSplit & "<a href="&pagename&"?keyword="&name&"&item="&theitem&"&pageid="&Pagestart-10&"><font face=webdings title=前十页>7</font></a>&nbsp;"                                                                                                  
for j=PageStart to Pageend                                                                                                  
if j > totalpage then exit for                                                                                                  
if j <> currentpage then                                                                                                  
strSplit = strSplit & "<a href="&pagename&"?keyword="&name&"&item="&theitem&"&pageid="&j&">["&j&"]</a>&nbsp;"			                                                                                                  
else                                                                                                  
strSplit = strSplit & "<font color=red>["&j&"]</font>&nbsp;"                                                                                                  
end if                                                                                                  
next                                                                                                  
if Sp*10  < totalpage then strSplit = strSplit & "<a href="&pagename&"?keyword="&name&"&item="&theitem&"&pageid="&Pagestart+10&"><font face=webdings title=后十页>8</font></a>"                                                                                                   
strSplit = strSplit & "<a href="&pagename&"?keyword="&name&"&item="&theitem&"&pageid="&totalpage&" ><font face=webdings title=""最后一页"">:</font></a>"                                                                                                  
PageSet = strSplit                                                                                              
End Function                                                                       
%>
<!-- 这里是主题结束 -->
<!--#include file="foot.asp"-->