<%
'*************************************************
'函数名：DreamMenu
'作  用：显示网站主导航菜单
'参  数：classname   ---- 样式名称
'        strUrl      ---- 分割线
'        menuname    ---- 当前栏目名称
'返回值：导航菜单
'*************************************************

function DreamMenu(classname,strUrl,menuname)
	if classname<>"" then
	classname=" class="""&classname&""""
	end if
	
	if strUrl<>"" then
	strUrl="<li><img src="""&strUrl&"""></li>"
	end if	
		
	set rs=server.createobject("adodb.recordset")
	sql="select * from Dream_Menu where Dream_Show=true order by Dream_Zid asc"		
	rs.open sql,conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	if menuname=rs("Dream_Names") then
	str_all=str_all&"<li"&classname&"><a href="""&rs("Dream_Filename")&""">"&rs("Dream_Names")&"</a></li>"
	else
	str_all=str_all&"<li><a href="""&rs("Dream_Filename")&""">"&rs("Dream_Names")&"</a></li>"
	end if
	str_all=str_all&strUrl
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing	
	DreamMenu=str_all
end function


'*************************************************
'过程名：DreamPage
'作  用：显示单页文章
'参  数：title    ----  栏目名称
'        classid  ----  所属分类ID
'返回值：单页详细内容
'*************************************************
sub DreamPage(title,classid)
	set co=conn.execute("select * from [Dream_Page] where Dream_Title='"&title&"' and Dream_Classid="&classid)
	if not(co.eof and co.bof) then
	response.write co("Dream_Content")
	end if
	set co=nothing
end sub

'*************************************************
'过程名：DreamNewsList
'作  用：显示新闻列表
'参  数：classid    ----  分类ID
'        pagenum  ----  每页条数
'        page  ----  当前页面码
'返回值：新闻列表
'*************************************************
sub DreamNewsList(classid,pagenum,page)
	Set rs=Server.CreateObject("ADODB.RecordSet")
	sql="select * from Dream_News where Dream_Classid="&classid&" order by id desc"
	rs.open sql,conn,1,1
	if not(rs.eof and rs.bof) then
	rs.PageSize=pagenum
	if page=0 then page=1 
	pages=rs.pagecount
	if page > pages then page=pages
	rs.AbsolutePage=page
	for j=1 to rs.PageSize
	response.write "<li><a href=""view.asp?id="&rs("id")&"&Cid="&rs("Dream_Classid")&""" title="&rs("Dream_Title")&">"&rs("Dream_Title")&"</a><span>"&FormatDate(rs("Dream_UpdateTime"))&"</span></li>"
	rs.movenext
	if rs.eof then exit for
	next
	else
	response.write "<li>此栏目暂无任何新增信息</li>"
	end if
	session("pagecount")=rs.pagecount
	session("recordcount")=rs.recordcount
	session("PageSize")=rs.PageSize
	rs.close
	set rs=nothing
	
end sub


'*************************************************
'过程名：DreamImgList
'作  用：显示图集类列表
'参  数：classid    ----  分类ID
'        pagenum  ----  每页条数
'        page  ----  当前页面码
'        imgwidth  ----  图片宽度
'        imgheight  ----  图片高度
'返回值：图集列表
'*************************************************
sub DreamImgList(classid,pagenum,page,imgwidth,imgheight)
		
	Set rs=Server.CreateObject("ADODB.RecordSet")
	sql="select * from Dream_Img where Dream_Classid="&classid&" order by id desc"
	rs.open sql,conn,1,1
	if not(rs.eof and rs.bof) then
	rs.PageSize=pagenum
	if page=0 then page=1 
	pages=rs.pagecount
	if page > pages then page=pages
	rs.AbsolutePage=page  
	for j=1 to rs.PageSize
	if rs("Dream_DefaultPicUrl")<>"" then
	DefaultPicUrl=rs("Dream_DefaultPicUrl")
	else
	DefaultPicUrl="images/no_img.jpg"
	end if
	response.write "<li><a href=""view.asp?id="&rs("id")&"&Cid="&rs("Dream_Classid")&""" title="&rs("Dream_Title")&"><img width="&imgwidth&" height="&imgheight&" src="&DefaultPicUrl&"><br>"&mid(rs("Dream_Title"),1,12)&"</a></li>"
	rs.movenext
	if rs.eof then exit for
	next
	else
	response.write "<li>此栏目暂无任何新增信息</li>"
	end if
	session("pagecount")=rs.pagecount
	session("recordcount")=rs.recordcount
	session("PageSize")=rs.PageSize
	rs.close
	set rs=nothing
end sub


'*************************************************
'过程名：DreamProList
'作  用：显示产品类列表
'参  数：classid    ----  分类ID
'        pagenum  ----  每页条数
'        page  ----  当前页面码
'        imgwidth  ----  图片宽度
'        imgheight  ----  图片高度
'返回值：图集列表
'*************************************************
sub DreamProList(classid,pagenum,page,imgwidth,imgheight)
		
	Set rs=Server.CreateObject("ADODB.RecordSet")
	sql="select * from Dream_Products where Dream_Classid="&classid&" order by id desc"
	rs.open sql,conn,1,1
	if not(rs.eof and rs.bof) then
	rs.PageSize=pagenum
	if page=0 then page=1 
	pages=rs.pagecount
	if page > pages then page=pages
	rs.AbsolutePage=page  
	for j=1 to rs.PageSize
	if rs("Dream_DefaultPicUrl")<>"" then
	DefaultPicUrl=rs("Dream_DefaultPicUrl")
	else
	DefaultPicUrl="images/no_img.jpg"
	end if
	response.write "<li><a href=""view.asp?id="&rs("id")&"&Cid="&rs("Dream_Classid")&""" title="&rs("Dream_Title")&"><img width="&imgwidth&" height="&imgheight&" src="&DefaultPicUrl&"><br>"&mid(rs("Dream_Title"),1,12)&"</a></li>"
	rs.movenext
	if rs.eof then exit for
	next
	else
	response.write "<li>此栏目暂无任何新增信息</li>"
	end if
	session("pagecount")=rs.pagecount
	session("recordcount")=rs.recordcount
	session("PageSize")=rs.PageSize
	rs.close
	set rs=nothing
end sub

'*************************************************
'过程名：centpage
'作  用：显示分页
'参  数：namess    ----  分类ID
'        page  ----  当前页面码
'返回值：分页
'*************************************************
sub centpage(namess,Page)
	if Page<2 then      
		response.write "首页 上一页&nbsp;"
	else
		response.write "<a href=?names="&Server.UrlEncode(namess)&"&page=1>首页</a>&nbsp;"
		response.write "<a href=?names="&Server.UrlEncode(namess)&"&page=" & Page-1 & ">上一页</a>&nbsp;"
	end if
		if session("pagecount")-page<1 then
		response.write "下一页 尾页"
	else
		response.write "<a href=?names="&Server.UrlEncode(namess)&"&page=" & (page+1) & ">"
		response.write "下一页</a> <a href=?names="&Server.UrlEncode(namess)&"&page="&session("pagecount")&">尾页</a>"
	end if
		response.write "&nbsp;页次：<strong><span class=red>"&Page&"</span>/"&session("pagecount")&"</strong>页 "
		response.write "&nbsp;共<b><span class=red>"&session("recordcount")&"</span></b>条记录 <b>"&session("pagesize")&"</b>条记录/页"
end sub


'*************************************************
'函数名：leftmenu
'作  用：显示侧栏分类
'参  数：BigClassID    ----  一级分类ID
'        namess  ----  当前分类
'返回值：分类内容
'*************************************************
function leftmenu(BigClassID,namess,nums)
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Dream_MenuClass where Dream_ClassID="&BigClassID&" or Dream_ClassID = (select Dream_ClassID from Dream_MenuClass where ID="&BigClassID&" and Dream_ClassID<>0) order by Dream_zid asc, id asc"
	'sql="select * from Dream_MenuClass where Dream_Classid="&BigClassID&" order by Dream_Zid asc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	if namess="" then 
	namess=rs("Dream_Names")
	nums=100+rs("id")	
	end if
	if namess=rs("Dream_Names") then 
	nums=100+rs("id")
	classname=" class=""selected"""
	session("id")=rs("id")
	session("style")=rs("Dream_Style")
	else
	classname=""
	end if
	leftmenu=leftmenu&"<li"&classname&"><a href="""&rs("Dream_Filename2")&"?names="&Server.UrlEncode(rs("Dream_Names"))&""">"&rs("Dream_Names")&"</a></li>"
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
	leftmenu=leftmenu
end function



'*************************************************
'函数名：view
'作  用：显示详细内容
'参  数：ID    ----  ID
'        ClassID  ----  所属分类
'        DreamTitle  ----  标题
'        DreamContent  ----  内容
'        DreamTitles  ----  网页标题
'        DreamKeys  ----  关健词
'        DreamDes  ----  描述
'        DreamNames   ---- 分类名称 
'        DreamUrl   ---- 链接页面
'        BigClassID   ---- 大类ID
'        Namess  ----- 小类名称
'        DreamUser ---- 发布人
'        DreamDate  --- 发布时间
'返回值：详细内容
'*************************************************
function view(ID,ClassID,DreamTitle,DreamContent,DreamTitles,DreamKeys,DreamDes,DreamNames,DreamUrl,BigClassID,Namess,DreamUser,DreamDate)
	
	set co=conn.execute("select Dream_Names,Dream_Style,Dream_Classid from Dream_MenuClass where ID="&ClassID)
	if not(co.eof and co.bof) then
	Dream_Style=co("Dream_Style")
	if Dream_Style=2 then
	DreamDate="Dream_News"
	elseif Dream_Style=3 then
	DreamDate="Dream_Img"
	elseif Dream_Style=5 then
	DreamDate="Dream_Products"
	end if
	namess=co("Dream_Names")
	if co("Dream_Classid")<>0 then
	BigClassID=co("Dream_Classid")
	else
	BigClassID=co("id")	
	end if
	end if
	set co=nothing	

	set co=conn.execute("select Dream_Names,Dream_Filename2 from Dream_MenuClass where ID="&BigClassID)
	if not(co.eof and co.bof) then
	DreamNames=co("Dream_Names")
	DreamUrl=co("Dream_Filename2")
	set co=nothing
	end if
	
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from "&DreamDate&" where id="&ID
	rs.open sql,Conn,1,3
	if not(rs.eof and rs.bof) then
	DreamTitle=rs("Dream_title")
	DreamContent=rs("Dream_content")
	DreamTitles=rs("Dream_title")
	DreamKeys=rs("Dream_Keyword")
	DreamDes=rs("Dream_Description")
	DreamUser=rs("Dream_User")
	DreamDate=rs("Dream_UpdateTime")
	end if
	rs.close
	rs.nothing
	
	view=newstitle
end function


'*************************************************
'过程名：i_leftmenu
'作  用：显示首页侧栏分类
'参  数：BigClassID    ----  一级分类ID
'        strNum  ----  显示个数 等于0表示取出全部数据
'返回值：分类内容
'*************************************************
sub i_leftmenu(BigClassID,strNum)
	set rs=server.CreateObject("adodb.recordset")
	if strNum=0 then
	sql="select * from Dream_MenuClass where Dream_Classid="&BigClassID&" order by Dream_zid asc,id asc"
	else
	sql="select top "&strNum&" * from Dream_MenuClass where Dream_Classid="&BigClassID&" order by Dream_zid asc,id asc"
	end if
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	response.Write "<li><a href="""&rs("Dream_Filename2")&"?names="&Server.UrlEncode(rs("Dream_Names"))&""">"&rs("Dream_Names")&"</a></li>"
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
end sub


'*************************************************
'过程名：i_page
'作  用：显示首页单页数据
'参  数：BigClassID    ----  一级分类ID
'        strNum  ----  显示字数
'返回值：单页数据
'*************************************************
sub i_page(BigClassID,strNum)
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Dream_Page where Dream_Classid="&BigClassID&" order by id asc"	
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	response.Write gotTopic(ClearHtml(rs("Dream_Content"),1),strNum*2)	
	end if
	rs.close
	set rs=nothing
end sub

'*************************************************
'过程名：i_news
'作  用：显示首页新闻数据
'参  数：BigClassID    ----  分类ID 当为一级类ID时，则取所有子类的数据；为0时，则取所有新闻类的数据。
'        strTpl  ----  显示条数
'        strNum  ----  每条字数
'返回值：新闻数据
'*************************************************
sub i_news(BigClassID,strTpl,strNum)
	set rs=server.CreateObject("adodb.recordset")
	if BigClassID = 0 then
	sql="select top "&strTpl&" * from Dream_News order by id asc"
	else
	sql="select top "&strTpl&" * from Dream_News where Dream_Classid in (select id from Dream_MenuClass where Dream_Classid="&BigClassID&" or id="&BigClassID&") order by id desc"
	end if	
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	response.Write "<li><a href=""view.asp?id="&rs("id")&"&Cid="&rs("Dream_Classid")&""" title="""&rs("Dream_Title")&""">"&gotTopic(rs("Dream_Title"),strNum*2)&"</a></li>"
	rs.movenext
	loop	
	end if
	rs.close
	set rs=nothing
end sub

'*************************************************
'过程名：i_pro
'作  用：显示首页图集产品类数据
'参  数：BigClassID    ----  分类ID 当为一级类ID时，则取所有子类的数据；不可为0。
'        strTpl  ----  显示条数
'        strNum  ----  每条字数
'返回值：产品数据
'*************************************************
sub i_pro(BigClassID,strTpl,strNum)
	set rs=server.CreateObject("adodb.recordset")
	sql="select top "&strTpl&" * from Dream_Products where Dream_Classid in (select id from Dream_MenuClass where Dream_Classid="&BigClassID&" or id="&BigClassID&") and Dream_Elite=true order by id desc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	response.Write "<table border=""0"" cellpadding=""5"" cellspacing=""0""><tr>"
	do while not rs.eof
	response.Write "<td><a href=""view.asp?id="&rs("id")&"&Cid="&rs("Dream_Classid")&""" title="""&rs("Dream_Title")&"""><img src="""&rs("Dream_DefaultPicUrl")&"""><br>"&gotTopic(rs("Dream_Title"),strNum*2)&"</a></td>"
	rs.movenext
	loop
	response.Write "</tr></table>"	
	end if
	rs.close
	set rs=nothing
end sub



'*************************************************
'过程名：i_case
'作  用：显示首页案例数据
'参  数：BigClassID    ----  分类ID 当为一级类ID时，则取所有子类的数据；不可为0。
'        strTpl  ----  显示条数
'        strNum  ----  每条字数
'返回值：案例数据
'*************************************************
sub i_case(BigClassID,strTpl,strNum,strNum2)
	set rs=server.CreateObject("adodb.recordset")
	sql="select top "&strTpl&" * from Dream_Img where Dream_Classid in (select id from Dream_MenuClass where Dream_Classid="&BigClassID&" or id="&BigClassID&") and Dream_Elite=true order by id desc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	response.Write "<li><img src="""&rs("Dream_DefaultPicUrl")&"""><a href=""view.asp?id="&rs("id")&"&Cid="&rs("Dream_Classid")&""" title="""&rs("Dream_Title")&""">"&gotTopic(rs("Dream_Title"),strNum*2)&"</a><span>"&gotTopic(ClearHtml(rs("Dream_Content"),0),strNum2*2)&"</span></li>"
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
end sub



'*************************************************
'过程名：DreamLink
'作  用：显示首页友情链接
'参  数：strTpl  ----  显示条数
'        strNum  ----  显示条数
'返回值：首页友情
'*************************************************
sub DreamLink(strTpl,strNum)
	set rs=server.CreateObject("adodb.recordset")
	sql="select top "&strTpl&" * from FriendLinks order by id asc"	
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	response.Write "<li><a href="""&rs("SiteUrl")&""" target=""_blank"">"&gotTopic(rs("SiteName"),strNum*2)&"</a></li>"
	rs.movenext
	loop	
	end if
	rs.close
	set rs=nothing
end sub

'*************************************************
'过程名：DreamLinkList
'作  用：显示友情链接列表
'参  数：strTpl  ----  每页条数
'        page  ----  当前页码
'返回值：首页友情
'*************************************************
sub DreamLinkList(strTpl,page)
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from FriendLinks order by id asc"	
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	rs.PageSize=strTpl
	if page=0 then page=1 
	pages=rs.pagecount
	if page > pages then page=pages
	rs.AbsolutePage=page  
	for j=1 to rs.PageSize
	response.Write "<li><a href="""&rs("SiteUrl")&""" target=""_blank"">"&rs("SiteName")&"</a><span>"&rs("SiteUrl")&"</span></li>"
	rs.movenext
	if rs.eof then exit for
	next
	else
	response.write "<li>此栏目暂无任何新增信息</li>"
	end if
	session("pagecount")=rs.pagecount
	session("recordcount")=rs.recordcount
	session("PageSize")=rs.PageSize
	rs.close
	set rs=nothing
end sub


'*************************************************
'过程名：DreamSearch
'作  用：显示查询
'参  数：classid    ----  分类ID
'        pagenum  ----  每页条数
'        page  ----  当前页面码
'        imgwidth  ----  图片宽度
'        imgheight  ----  图片高度
'返回值：查询结果
'*************************************************
sub DreamSearch(classid,keys)	
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Dream_MenuClass where id="&classid&" order by Dream_Zid asc"
	rs.open sql,Conn,1,1
	if not rs.eof then
	style=rs("Dream_Style")
	end if	
	rs.close
	set rs=nothing
	if style=2 then
	strData="Dream_News"
	strUrl="news_show.asp"
	elseif style=5 then
	strData="Dream_Products"
	strUrl="pro_show.asp"
	elseif style=3 then
	strData="Dream_Img"
	strUrl="img_show.asp"
	end if

	Set rs=Server.CreateObject("ADODB.RecordSet")
	sql="select * from "&strData&" where Dream_Title like '%"&keys&"%' and Dream_ClassID="&classid&" order by id desc"
	rs.open sql,conn,1,1 
	response.write "<div>共搜索到含有关健词“ <font color=red><b>"&keys&"</b></font> ”的数据 <font color=red>"&rs.recordcount&"</font> 条</div>"
	if not rs.eof then	
	do while not rs.eof
	Dream_Title=replace(rs("Dream_Title"),keys,"<font color=red>"&keys&"</font>")
	response.write "<li><a href="""&strUrl&"?id="&rs("id")&""" title="&rs("Dream_Title")&">"&Dream_Title&"</a><span>"&FormatDate(rs("Dream_UpdateTime"))&"</span></li>"
	rs.movenext
	loop
	else
	response.write "<li>没有搜索到任何信息！</li>"
	end if	
	rs.close
	set rs=nothing	
end sub

sub DreamSearchClass
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Dream_MenuClass where Dream_Style in (2,3,5) and Dream_Classid<>0 order by Dream_Zid asc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	response.write "<OPTION value="""&rs("id")&""">-> "&rs("Dream_Names")&"</OPTION>"
	rs.movenext
	loop
	end if
	rs.close
	set rs=nothing
end sub

'*************************************************
'函数名：gotTopic
'作  用：截字符串，汉字一个算两个字符，英文算一个字符
'参  数：str   ----原字符串
'       strlen ----截取长度
'返回值：截取后的字符串
'*************************************************
function gotTopic(str,strlen)
	if str="" then
		gotTopic=""
		exit function
	end if
	dim l,t,c, i
	'str=replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
	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
			gotTopic=left(str,i) & "…"
			exit for
		else
			gotTopic=str
		end if
	next
	gotTopic=gotTopic
	'gotTopic=replace(replace(replace(replace(gotTopic," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function
'**********************************************
'函数名：GetCount(InfoId,TableName,Teams)
'**********************************************
Function GetCount(InfoId,TableName,Teams)
	If Teams="0" then
		sql="select "&InfoId&" from ["&TableName&"] "
	Else
		sql="select "&InfoId&" from ["&TableName&"] "&Teams&""
	End If
	set rs=server.createobject("adodb.recordset")
	rs.open sql,Conn,1,1
	GetCount=rs.recordcount
	rs.close:set rs=nothing
End Function
'***********************************************
'函数名：JoinChar
'作  用：向地址中加入 ? 或 &
'参  数：strUrl  ----网址
'返回值：加了 ? 或 & 的网址
'***********************************************
function JoinChar(strUrl)
	if strUrl="" then
		JoinChar=""
		exit function
	end if
	if InStr(strUrl,"?")<len(strUrl) then 
		if InStr(strUrl,"?")>1 then
			if InStr(strUrl,"&")<len(strUrl) then 
				JoinChar=strUrl & "&"
			else
				JoinChar=strUrl
			end if
		else
			JoinChar=strUrl & "?"
		end if
	else
		JoinChar=strUrl
	end if
end function
'***********************************************
'过程名：showpage
'作  用：显示“上一页 下一页”等信息
'参  数：sfilename  ----链接地址
'       totalnumber ----总数量
'       maxperpage  ----每页数量
'       ShowTotal   ----是否显示总数量
'       ShowAllPages ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用，否则会出现JS错误。
'       strUnit     ----计数单位
'***********************************************
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
	dim n, i,strTemp,strUrl
	if totalnumber mod maxperpage=0 then
    	n= totalnumber \ maxperpage
  	else
    	n= totalnumber \ maxperpage+1
  	end if
  	strTemp= "<form name='showpages' method='Post' action='" & sfilename & "'><table align='center' height='40'><tr><td>"
	if ShowTotal=true then 
		strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
	end if
	strUrl=JoinChar(sfilename)
  	if CurrentPage<2 then
    		strTemp=strTemp & "首页 上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='?page=1&classid="&classid&"'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='?page=" & (CurrentPage-1) & "&classid="&classid&"'>上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		strTemp=strTemp & "下一页 尾页"
  	else
    		strTemp=strTemp & "<a href='?page=" & (CurrentPage+1) & "&classid="&classid&"'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='?page=" & n & "&classid="&classid&"'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
	if ShowAllPages=True then
		strTemp=strTemp & "&nbsp;转到：<select name='page' size='1' onchange='javascript:submit()'>"   
    	for i = 1 to n   
    		strTemp=strTemp & "<option value='" & i & "'"
			if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
			strTemp=strTemp & ">第" & i & "页</option>"   
	    next
		strTemp=strTemp & "</select>"
	end if
	strTemp=strTemp & "</td></tr></table></form>"
	response.write strTemp
end sub

sub showpages(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit,classid)
	dim n, i,strTemp,strUrl
	if totalnumber mod maxperpage=0 then
    	n= totalnumber \ maxperpage
  	else
    	n= totalnumber \ maxperpage+1
  	end if
  	strTemp= "<form name='showpages' method='Post' action='" & sfilename & "'><table align='center' height='40'><tr><td>"
	if ShowTotal=true then 
		strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
	end if
	strUrl=JoinChar(sfilename)
  	if CurrentPage<2 then
    		strTemp=strTemp & "首页 上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='?page=1&classid="&classid&"'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='?page=" & (CurrentPage-1) & "&classid="&classid&"'>上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		strTemp=strTemp & "下一页 尾页"
  	else
    		strTemp=strTemp & "<a href='?page=" & (CurrentPage+1) & "&classid="&classid&"'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='?page=" & n & "&classid="&classid&"'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/页"
	if ShowAllPages=True then
		strTemp=strTemp & "&nbsp;转到：<select name='page' size='1' onchange='javascript:submit()'>"   
    	for i = 1 to n   
    		strTemp=strTemp & "<option value='" & i & "'"
			if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
			strTemp=strTemp & ">第" & i & "页</option>"   
	    next
		strTemp=strTemp & "</select>"
	end if
	strTemp=strTemp & "</td></tr></table></form>"
	response.write strTemp
end sub
%>
<%
'********************************************
'函数名：checkurl
'作  用：检查合法性
'********************************************
  
'********************************************
'函数名：IsValidEmail
'作  用：检查Email地址合法性
'参  数：email ----要检查的Email地址
'返回值：True  ----Email地址合法
'       False ----Email地址不合法
'********************************************
function IsValidEmail(email)
	dim names, name, i, c
	IsValidEmail = true
	names = Split(email, "@")
	if UBound(names) <> 1 then
	   IsValidEmail = false
	   exit function
	end if
	for each name in names
		if Len(name) <= 0 then
			IsValidEmail = false
    		exit function
		end if
		for i = 1 to Len(name)
		    c = Lcase(Mid(name, i, 1))
			if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
		       IsValidEmail = false
		       exit function
		     end if
	   next
	   if Left(name, 1) = "." or Right(name, 1) = "." then
    	  IsValidEmail = false
	      exit function
	   end if
	next
	if InStr(names(1), ".") <= 0 then
		IsValidEmail = false
	   exit function
	end if
	i = Len(names(1)) - InStrRev(names(1), ".")
	if i <> 2 and i <> 3 then
	   IsValidEmail = false
	   exit function
	end if
	if InStr(email, "..") > 0 then
	   IsValidEmail = false
	end if
end function

'***************************************************
'函数名：IsObjInstalled
'作  用：检查组件是否已经安装
'参  数：strClassString ----组件名
'返回值：True  ----已经安装
'       False ----没有安装
'***************************************************
Function IsObjInstalled(strClassString)
	On Error Resume Next
	IsObjInstalled = False
	Err = 0
	Dim xTestObj
	Set xTestObj = Server.CreateObject(strClassString)
	If 0 = Err Then IsObjInstalled = True
	Set xTestObj = Nothing
	Err = 0
End Function

'**************************************************
'函数名：strLength
'作  用：求字符串长度。汉字算两个字符，英文算一个字符。
'参  数：str  ----要求长度的字符串
'返回值：字符串长度
'**************************************************
function strLength(str)
	ON ERROR RESUME NEXT
	dim WINNT_CHINESE
	WINNT_CHINESE    = (len("中国")=2)
	if WINNT_CHINESE then
        dim l,t,c
        dim i
        l=len(str)
        t=l
        for i=1 to l
        	c=asc(mid(str,i,1))
            if c<0 then c=c+65536
            if c>255 then
                t=t+1
            end if
        next
        strLength=t
    else 
        strLength=len(str)
    end if
    if err.number<>0 then err.clear
end function
Function Unknown()
%>

<%End Function

'****************************************************
'过程名：WriteErrMsg
'作  用：显示错误提示信息
'参  数：无
'****************************************************
sub WriteErrMsg()
	dim strErr
	strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
	strErr=strErr & "<link href='inc/style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
	strErr=strErr & "<div id='container'>" & vbcrlf
	strErr=strErr & "<div id='right'>您现在的位置：<a href='admin_Index_Main.asp'>管理首页</a> >> 错误信息</div>" & vbcrlf
	strErr=strErr & "<div id='right_1'><img src='images/xiao.jpg' /> 错误信息</div>" & vbcrlf
	strErr=strErr & "<div id='contents'>" & vbcrlf
	strErr=strErr & "<table cellpadding=0 cellspacing=1 border=0 width=95% align=center>" & vbcrlf
	strErr=strErr & "  <tr><td height='100' valign='top'><br><b>产生错误的可能原因：</b><br>" & errmsg &"<li>其它未知错误，请确定程序是否正常注册，或者咨询相关技术人员！</td></tr>" & vbcrlf
	strErr=strErr & "  <tr><td class='title'><a href='javascript:history.go(-1)'>&lt;&lt; 返回上一页</a></td></tr>" & vbcrlf
	strErr=strErr & "</table>" & vbcrlf
	strErr=strErr & "</body></html>" & vbcrlf
	response.write strErr
end sub

'****************************************************
'过程名：WriteSuccessMsg
'作  用：显示成功提示信息
'参  数：无
'****************************************************
sub WriteSuccessMsg(SuccessMsg)
	dim strSuccess
	strSuccess=strSuccess & "<html><head><title>成功信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
	strSuccess=strSuccess & "<link href='inc/Admin_Style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
	strSuccess=strSuccess & "<table cellpadding=0 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
	strSuccess=strSuccess & "  <tr align='center'><td height='20' class='title'><strong>恭喜你！</strong></td></tr>" & vbcrlf
	strSuccess=strSuccess & "  <tr><td height='100' class='tdbg' valign='top'><br>" & SuccessMsg &"</td></tr>" & vbcrlf
	strSuccess=strSuccess & "  <tr align='center'><td class='title'><a href='javascript:history.back()'>【返 回】</a></td></tr>" & vbcrlf
	strSuccess=strSuccess & "</table>" & vbcrlf
	strSuccess=strSuccess & "</body></html>" & vbcrlf
	response.write strSuccess
end sub
Function UnExist(FolderName) 
set fso=Server.CreateObject ("Scripting.FileSystemObject")  
if fso.FileExists(server.MapPath (FolderName)) then 
	UnExist=True
else 
	UnExist=False 
end if
set fso=nothing
End Function
function HTMLEncode(fString)
fString = replace(fString,">",">")
fString = replace(fString,"<","<")
fString = Replace(fString,CHR(32)," ")
fString = Replace(fString,CHR(13),"")
fString = Replace(fString,CHR(10) & CHR(10),"<br>")
fString = Replace(fString,CHR(10),"<br>")
HTMLEncode = fString
end function

function ReHTMLEncode(fString)
fString = replace(fString,">",">")
fString = replace(fString,"<","<")
fString = Replace(fString," ",CHR(32))
fString = Replace(fString,"",CHR(13))
'fString = Replace(fString,"<br>",CHR(10) & CHR(10))
fString = Replace(fString,"<br>",CHR(10))
ReHTMLEncode = fString
end function
%>

