<%
set rs=server.CreateObject("adodb.recordset")
rs.open"select * from SiteConfig where SiteID=1",conn,1,1
if not rs.eof then
   SiteName=rs("SiteName")
   SiteTitle=rs("SiteTitle")
   SiteUrl=rs("SiteUrl")
   SiteKey=rs("SiteKey")
   SiteDesc=rs("SiteDesc")
   SiteBottom=rs("SiteBottom")
end if 
rs.close:set rs=nothing


Function IndexTopAd()
   Str=""
   set rs=server.CreateObject("adodb.recordset")
   rs.open"select * from [ad] order by id desc",conn,1,1
   do while not rs.eof 
      Str=Str&"<a href="""&Rs("AdLink")&""" title="""&Rs("AdName")&""" target=""_blank""><img src=""/"&Rs("AdFile")&""" width=""900"" height=""200"" border=""0"" /></a>"
   rs.movenext
   loop
   rs.close:set rs=nothing
   IndexTopAd=Str
End Function


Function CompanyNews(ClassID,num)
   Str=""
   set rs=server.CreateObject("Adodb.recordset")
   rs.open"select top "&num&" * from news where ClassID in ('"&replace(ClassID,",","','")&"') order by id desc",conn,1,1
   if not rs.eof then
	   do while not rs.eof
		  Str=Str&"<tr><td height=""28"" align=""left"">·<a href=""/news/"&rs("ID")&".html"" target=""_blank"" class=""pup"" title="""&rs("title")&"""><font color="""&rs("titlecolor")&""">"&left(trim(rs("title")),20)&"</font></a>&nbsp;</td></tr><tr><td height=""1"" background=""/Images/Icon.gif""></td></tr>"& vbcrlf
	   rs.movenext
	   loop
	   rs.close:set rs=nothing
   else
   	   Str=Str&"<tr><td height=""28"" align=""left"">·暂无信息</td></tr>"
   end if
   CompanyNews=Str
End Function

'========业务范围======
Function Business()
   Str=""
   set rs=server.CreateObject("Adodb.recordset")
   rs.open"select * From Article where ArtClass='业务范围' order by artid asc",conn,1,1

   if not rs.eof then
	   do while not rs.eof
	   
	    Str=Str&"<tr>"& vbcrlf
		Str=Str&"<td height=""28"" align=""left"" style=""padding-left:20px;""><img src=""/Images/Icon_1.gif"" />&nbsp;&nbsp;<a href=""/"&rs("HtmlFile")&""" class=""pup"" title="""&rs("ArtKeyWord")&""">"&rs("ArtTitle")&"</a></td>"& vbcrlf
	    Str=Str&"</tr>"& vbcrlf
	    Str=Str&"<tr>"& vbcrlf
		Str=Str&"<td height=""1"" bgcolor=""#EBEBEB""></td>"& vbcrlf
	    Str=Str&"</tr>"& vbcrlf
	    
	   rs.movenext
	   loop
	   rs.close:set rs=nothing
   else
   	   Str=Str&"<tr><td height=""28"" align=""left""></td></tr>"
   end if
   Business=Str
End Function


'Function BestProductList(num)
'   Str=""
'   set rs=server.CreateObject("Adodb.recordset")
'   'rs.open"select top "&num&" * from ProdList where IsBest=1 order by id desc",conn,1,1
'   rs.open"select * from ProdList where IsBest=1 order by id desc",conn,1,1
'   do while not rs.eof
'      Str=Str&"<div class=""Prod""><a href=""/Product/"&rs("ID")&".html"" title="""&rs("ProdName")&""" target=""_blank""><img src=""/"&rs("smallPic")&""" width=""205"" height=""150"" style=""border:6px solid #01253B;"" /></a><br />名称：<a href=""/Product/"&rs("ID")&".html"" title="""&rs("ProdName")&""" target=""_blank"" class=""pup"">"&rs("ProdName")&"</a></div>	"& vbcrlf
'   rs.movenext
'   loop
'   rs.close:Set rs=nothing
'   BestProductList=Str
'End Function

Function BestProductList(num)
   Str=""
   set rs=server.CreateObject("Adodb.recordset")
   rs.open"select top "&num&" * from ProdList where IsBest=1 order by id desc",conn,1,1
   'rs.open"select * from ProdList where IsBest=1 order by id desc",conn,1,1
   do while not rs.eof
      Str=Str&"<div class=""Prod""><a href=""/Product/"&rs("ID")&".html"" title="""&rs("ProdName")&""" target=""_blank""><img src=""/"&rs("smallPic")&""" width=""205"" height=""150"" style=""border:6px solid #01253B;"" /></a><br />名称：<a href=""/Product/"&rs("ID")&".html"" title="""&rs("ProdName")&""" target=""_blank"" class=""pup"">"&rs("ProdName")&"</a></div>	"& vbcrlf
   rs.movenext
   loop
   rs.close:Set rs=nothing
   BestProductList=Str
End Function



Function Link()
   set rs=server.CreateObject("Adodb.recordset")
   rs.open"select * from link order by id desc",conn,1,1
   do while not rs.eof
	  Str=Str&"<a href="&rs("LinkUrl")&" target=""_blank"" class=""pup"">"&rs("LinkName")&"</a>&nbsp;&nbsp;"
   rs.movenext
   loop
   rs.close:set rs=nothing
  
   Link=Str
End Function


Function News(maxPer,curID,FileName,curpage,totalpage)
   Str=""
   set rs=server.CreateObject("Adodb.recordset")
   if curpage<2 then
   rs.open"select top "&maxPer&" * from News where ClassID='行业动态' or ClassID='建站知识' order by id desc",conn,1,1
   else
   rs.open"select top "&maxPer&" * from News where (ClassID='行业动态' or ClassID='建站知识') and ID not in(select top "&(curpage-1)*maxPer&" ID from News where  (ClassID='行业动态' or ClassID='建站知识') order by id desc ) order by id desc",conn,1,1
   end if
   do while not rs.eof
      Str=Str&"<div style=""line-height:25px;"">&nbsp;&nbsp;&nbsp;·&nbsp;<a href=""/news/"&rs("id")&".html"" target=""_blank"" class=""pup""><font color="""&rs("titlecolor")&""">"&rs("Title")&"</font></a>&nbsp;&nbsp;&nbsp;&nbsp;"&formatdatetime(rs("AddDate"),vbshortdate)&"</div>" & vbcrlf
   rs.movenext
   loop
   rs.close:Set rs=nothing
   Str=Str&FenYe(totalpage,curpage,FileName)
   News=Str
End Function


Function Cases(maxPer,curID,FileName,curpage,totalpage)
   Str=""
   set rs=server.CreateObject("Adodb.recordset")
   if curpage<2 then
   rs.open"select top "&maxPer&" * from ProdList order by id desc",conn,1,1
   else
   rs.open"select top "&maxPer&" * from ProdList where ID not in(select top "&(curpage-1)*maxPer&" ID from ProdList order by id desc ) order by id desc",conn,1,1
   end if
   do while not rs.eof
	  Str=Str&"<table width=""670"" height=""190"" border=""0"" cellpadding=""0"" cellspacing=""0"" style=""margin-top:5px;"">"& vbcrlf
	  Str=Str&"<tr>"& vbcrlf
	  Str=Str&"<td width=""235"" rowspan=""3"" align=""center"" valign=""top"">"& vbcrlf
	  Str=Str&"<div class=""Prod2""><a href=""/Product/"&rs("ID")&".html"" title="""&rs("ProdName")&""" target=""_blank""><img src=""/"&rs("smallPic")&""" width=""205"" height=""150"" style=""border:6px solid #01253B;"" /><br /></div></td>"& vbcrlf
      Str=Str&"<td width=""425"" height=""31"" align=""left""><strong>名称：</strong><a href=""/Product/"&rs("ID")&".html"" class=""pupb"" title="""&rs("ProdName")&""" target=""_blank"">"&rs("ProdName")&"</a></td></tr>"    & vbcrlf
      Str=Str&"<tr><td height=""32"" align=""left""><strong>网址：</strong>"&rs("ModeUrl")&"</td></tr>"  & vbcrlf  
      Str=Str&"<tr>" & vbcrlf
      Str=Str&"<td height=""127"" align=""left"" valign=""top"" style=""line-height:23px;""><strong>介绍：</strong>"&left(RemoveHTML(Trim(rs("Content"))),100)&"...</td>"& vbcrlf
      Str=Str&"</tr></table>"& vbcrlf
   rs.movenext
   loop
   rs.close:Set rs=nothing
   Str=Str&FenYe(totalpage,curpage,FileName)
   Cases=Str
End Function



Function ShowNews(ID)
   Str=""
   set rs=server.CreateObject("Adodb.recordset")
   rs.open"select * from News where ID="&ID,conn,1,1
   if not rs.eof then
      Str=Str&"<div>"&rs("Content")&"</div>	"
   end if
   rs.close:Set rs=nothing
   ShowNews=Str
End Function




Function ShowCase(ID)
   Str=""
   set rs=server.CreateObject("Adodb.recordset")
   rs.open"select * from ProdList where ID="&ID,conn,1,1
   if not rs.eof then
      Str=Str&"<img src=""/"&Rs("BigPic")&""" width=""600"" style=""margin:10px;"" /><br><a href=""/Product/"&rs("ID")&".html"" title="""&rs("ProdName")&""">"&rs("ProdName")&"</a><br>"&rs("ModeUrl")&"</div>	"
   end if
   rs.close:Set rs=nothing
   ShowCase=Str
End Function



'===关键词===================
Function Keyword()
   Str="相关链接："
   set rs=server.CreateObject("Adodb.recordset")
   rs.open"select * from Keyword Order by id asc",conn,1,1
   do while not rs.eof
      Str=Str&"<strong><a href="""&rs("KeyLink")&""" title="""&rs("KeyName")&""" class=""pup"">"&rs("KeyName")&"</a></strong>&nbsp;"
   rs.movenext
   loop
   rs.close:Set rs=nothing
   Keyword=Str
End Function


'==========分页==============
Function FenYe(totalpage,curpage,FileName)
  Str="<div class=""black2"">"
  if curpage>1 then
     Str=Str&"<a href="""&FileName&"_"&curpage-1&".html"">前一页</a>"
  else
     Str=Str&"<span class=""disabled"">前一页</span>"
  end if
  totalpage=Clng(totalpage)
  if totalpage<10 then
     for i=1 to totalpage
	    if curpage=i then
	       Str=Str&"<span class=""current"">"&i&"</span>"
		else
		   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
		end if
	 next
  else
     if curpage<5 then
	    for i=1 to 8
			if curpage=i then
			   Str=Str&"<span class=""current"">"&i&"</span>"
			else
			   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
			end if
	    next
		Str=Str&"..."
		for i=totalpage-1 to totalpage
			if curpage=i then
			   Str=Str&"<span class=""current"">"&i&"</span>"
			else
			   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
			end if
	    next
	 elseif curpage>=5 and curpage<totalpage-5 then
	    for i=1 to 2
			if curpage=i then
			   Str=Str&"<span class=""current"">"&i&"</span>"
			else
			   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
			end if
	    next
		Str=Str&"..."
		for i=curpage-2 to curpage+2
			if curpage=i then
			   Str=Str&"<span class=""current"">"&i&"</span>"
			else
			   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
			end if
	    next
		Str=Str&"..."
		for i=totalpage-1 to totalpage
			if curpage=i then
			   Str=Str&"<span class=""current"">"&i&"</span>"
			else
			   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
			end if
	    next
	 elseif curpage>=totalpage-5 and curpage<=totalpage then
	    for i=1 to 2
			if curpage=i then
			   Str=Str&"<span class=""current"">"&i&"</span>"
			else
			   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
			end if
	    next
		Str=Str&"..."
		for i=totalpage-7 to totalpage
			if curpage=i then
			   Str=Str&"<span class=""current"">"&i&"</span>"
			else
			   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
			end if
	    next
	 end if
'	 for i=1 to totalpage
'	    if curpage=i then
'	       Str=Str&"<span class=""current"">"&i&"</span>"
'		else
'		   Str=Str&"<a href="""&FileName&"_"&i&".html"">"&i&"</a>"
'		end if
'	 next
	 
  end if
  if curpage=totalpage then
  	 Str=Str&"<span class=""disabled"">下一页</span></div>"
  else
 	 Str=Str&"<a href="""&FileName&"_"&curpage+1&".html"">下一页</a></div>"
  end if
  FenYe=Str
End Function


Function RemoveHTML(strHTML) 
	Dim objRegExp, Match, Matches 
	Set objRegExp = New Regexp 
	objRegExp.IgnoreCase = True 
	objRegExp.Global = True 
	'取闭合的<> 
	objRegExp.Pattern = "<.+?>" 
	'进行匹配 
	Set Matches = objRegExp.Execute(strHTML) 
	' 遍历匹配集合，并替换掉匹配的项目 
	For Each Match in Matches 
	strHtml=Replace(strHTML,Match.Value,"") 
	Next 
	RemoveHTML=strHTML 
	Set objRegExp = Nothing 
End Function


%>
