<%
'首页自定义函数
' 文件名称:Indexfunc.asp 
' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com
'=================================================================================================================================
'首页产品图片,num为图片数量,pwidth为图片宽度，pheight为图片高度
Function ComProducts(num,flag,pwidth,pheight)
Dim rs,sql,AutoLink,Str
Str=""
if flag="notice" then
sql="select top "&num&" ID,ProductName,smallPic from ["&Datapre&"_Products] where  ViewFlag and NewFlag order by OrderNum,id desc"
else
sql="select top "&num&" ID,ProductName,smallPic from ["&Datapre&"_Products] where  ViewFlag order by OrderNum,id desc"
end if
set rs=db(sql,2)
if not rs.eof then
 do while not rs.eof
 if IsHtml=0 then
 AutoLink="ProductView.asp?ID="&rs(0)&""
 else
 AutoLink=""&ProName&""&Separated&""&rs(0)&"."&HTMLName&""
 end if
 Str=Str&"<li><a href='"&AutoLink&"' target='_blank' title='"&rs(1)&"'><img src='"&rs(2)&"' width="&pwidth&">"
 Str=Str&"<span>"&rs(1)&"</span></a></li>"
 rs.movenext
 loop
end if
rs.close:set rs=nothing
ComProducts=Str
end function
'===================================================================================================================================
'过滤html并截取函数
Function cutStr(str,strlen) 
Dim re 
Set re=new RegExp 
re.IgnoreCase =True 
re.Global=True 
re.Pattern="<(.[^>]*)>" 
str=re.Replace(str,"") 
set re=Nothing 
Dim l,t,c,i 
l=Len(str) 
t=0 
For i=1 to l 
c=Abs(Asc(Mid(str,i,1))) 
If c>255 Then 
t=t+2 
Else 
t=t+1 
End If 
If t>=strlen Then 
cutStr=left(str,i)&"..." 
Exit For 
Else 
cutStr=str 
End If 
Next 
cutStr=Replace(cutStr,chr(10),"") 
cutStr=Replace(cutStr,chr(13)," ") 
cutStr=Replace(cutStr,"&nbsp;","") 
End Function 
'=========================================================================================
'首页公告新闻
function indexgg(num)
Dim rs,sql,str,AutoLink
str=""
sql="select top 1 ID,NewsName,smallpic,content from ["&Datapre&"_News] where Viewflag and NoticeFlag order by ID desc"
set rs=db(sql,2)
if not rs.eof then
if IsHtml=0 then
	AutoLink="NewsView.asp?ID="&rs(0)&""
else
	AutoLink=""&NewName&""&Separated&""&rs(0)&"."&HTMLName&""
end if	
str="<li class='clearfix'><a href='"&AutoLink&"' title='"&rs(1)&"'><img src='"&rs(2)&"' alt='"&rs(1)&"' width='110' height='80' /></a>"
str=str&"<h3><a href='"&AutoLink&"' title='"&rs(1)&"'>"&StrLeft(rs(1),20)&"</a></h3>"
str=str&"<p>"&cutstr(rs(3),50)&"<a href='"&AutoLink&"' title='"&rs(1)&"'>[详细]</a></p></li>"
end if
dim tid:tid=rs(0)
rs.close:set rs=nothing
sql="select top "&num&" ID,NewsName,AddTime from ["&Datapre&"_News] where Viewflag and ID<>"&tid&" order by ID desc"
set rs=db(sql,2)
	if not rs.eof then
		do while not rs.eof
		if IsHtml=0 then
	AutoLink="NewsView.asp?ID="&rs(0)&""
else
	AutoLink=""&NewName&""&Separated&""&rs(0)&"."&HTMLName&""
end if
		str=str&"<li><a href='"&AutoLink&"' title='"&rs(1)&"'><span>"&FormatDate(rs(2),12)&"</span>-&nbsp;"&strleft(rs(1),20)&"</a></li>"
		rs.movenext
		loop
	else
	str=str&"暂无信息"
	end if
rs.close:set rs=nothing
indexgg=str
end function

'==================================================================================================
'首页招聘列表
function indexjob(num)
Dim rs,sql,AutoLink,Str
Str=""
sql="select top "&num&" ID,JobName,startdate from ["&Datapre&"_Jobs] where  ViewFlag order by id desc"
set rs=db(sql,2)
if not rs.eof then
 do while not rs.eof
 if IsHtml=0 then
 AutoLink="JobsView.asp?ID="&rs(0)&""
 else
 AutoLink=""&JobNameDiy&""&Separated&""&rs(0)&"."&HTMLName&""
 end if
 Str=Str&"<li><a href='"&AutoLink&"' target='_blank' title='"&rs(1)&"'>"
 Str=Str&"<span>-&nbsp;&nbsp;"&rs(1)&"</span></a></li>"
 rs.movenext
 loop
end if
rs.close:set rs=nothing
indexjob=str
end function
%>