<%
function Review(Tid)	
	sql="select COUNT(Dream_Grade) as Grade_COUNT from Dream_Review where Dream_Look=true and Dream_ViewID="&Tid
	set rs=conn.execute(sql)
	if rs("Grade_COUNT")>0 then
	set rs=server.createobject("adodb.recordset")
	sql="select AVG(Dream_Grade) as Grade from Dream_Review where Dream_ViewID="&Tid
	rs.open sql,conn,1,1
	Review=FormatNumber(rs("Grade"),1,-1)	
	rs.close
	set rs=nothing
	else
	Review=0
	end if
end function

function ReviewNum(Tid)	
	sql="select COUNT(Dream_Grade) as Grade_COUNT from Dream_Review where Dream_Look=true and Dream_ViewID="&Tid
	set rs=conn.execute(sql)
	if rs("Grade_COUNT")>0 then
	ReviewNum=rs("Grade_COUNT")
	else
	ReviewNum=0
	end if
end function

function GoodsNum(cid)
	if request.cookies("cityall")<>"" then
	Dream_AreaStr=" and Dream_Area in ("&request.cookies("cityall")&")"
	end if
	sqls="select COUNT(id) as Goods_COUNT from Dream_Menpiao where Dream_IsOK=true and Dream_Theme in (select id from Dream_Theme where Dream_ClassID="&cid&" or id="&cid&" order by dream_zid asc,id desc) "&Dream_AreaStr
	set rss=conn.execute(sqls)
	if rss("Goods_COUNT")>0 then
	GoodsNum=rss("Goods_COUNT")
	else
	GoodsNum=0
	end if
end function

function userrz(userid)
	userrzstr="no"
	set rsuser=server.CreateObject("adodb.recordset")
	sqluser="select top 1 * from Dream_User where Dream_UserName='"&userid&"' order by id desc"
	rsuser.open sqluser,Conn,1,1	
	if not(rsuser.eof and rsuser.bof) then
	if rsuser("Dream_IdentityOK")<>"" and rsuser("Dream_IdentityOK")="通过验证" then
	userrzstr="yes"
	end if
	end if
	rsuser.close
	set rsuser=nothing
	userrz=userrzstr
end function

function menupc(dqcid,stlnum)
	set rs=server.CreateObject("adodb.recordset")
	sql="select top "&stlnum&" * from Dream_Theme where Dream_IsMenu=true order by Dream_zid asc, id desc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	url="list.asp?cid="&rs("id")
	if int(dqcid)=rs("id") then
	menupc=menupc&"<li><a href="""&url&""" class=""suba"" title="""&rs("Dream_Names")&""">"&rs("Dream_Names")&"</a></li>"
	else	
	menupc=menupc&"<li><a href="""&url&""" title="""&rs("Dream_Names")&""">"&rs("Dream_Names")&"</a></li>"
	end if
	rs.movenext
	loop	
	end if
	rs.close
	set rs=nothing
	menupc=menupc
end function

function menuhot(stlnum)
	set rs=server.CreateObject("adodb.recordset")
	sql="select top "&stlnum&" * from Dream_Theme where Dream_IsHot=true order by Dream_zid asc, id desc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	url="list.asp?cid="&rs("id")
	menuhot=menuhot&"<a href="""&url&""" title="""&rs("Dream_Names")&""">"&rs("Dream_Names")&"</a>"
	rs.movenext
	loop	
	end if
	rs.close
	set rs=nothing
	menuhot=menuhot
end function

function leftmenu_b(cid)
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Dream_Theme where Dream_ClassID=0 order by Dream_zid asc, id desc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	url="list.asp?cid="&rs("id")
	leftmenu_b=leftmenu_b&"<li class=""navhand""><h3 class=""""><i class=""id_"&rs("id")&"""></i><a href="""&url&""">"&rs("Dream_Names")&"</a><span>&gt;</span></h3></li>"		
	rs.movenext
	loop	
	end if
	rs.close
	set rs=nothing
	leftmenu_b=leftmenu_b
end function

function leftmenu_s(cid)
	leftmenu_s=""
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Dream_Theme where Dream_ClassID=0 order by Dream_zid asc, id desc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
		leftmenu_s=leftmenu_s&"<div class=""menulist""><div class=""menucon"">"
		set rss=server.CreateObject("adodb.recordset")
		sqls="select * from Dream_Theme where Dream_ClassID="&rs("id")&" order by Dream_zid asc, id desc"
		rss.open sqls,Conn,1,1
		if not(rss.eof and rss.bof) then	
		do while not rss.eof
		url="list.asp?cid="&rss("id")
		leftmenu_s=leftmenu_s&"<a href="""&url&""" title="""&rss("Dream_Names")&""">"&rss("Dream_Names")&"</a>"		
		rss.movenext
		loop	
		end if
		rss.close
		set rss=nothing
		leftmenu_s=leftmenu_s&"</div></div>"	
	rs.movenext
	loop
	end if
	
	rs.close
	set rs=nothing
	leftmenu_s=leftmenu_s
end function

function icompany(typeid,stlnum)

	if typeid="hot" then
	typesql="and Dream_Hot=true"
	end if
	
	if typeid="choice" then
	typesql="and Dream_Choice=true"
	end if
	
	if request.cookies("cityall")<>"" then
	typesql=typesql&" and Dream_Area in ("&request.cookies("cityall")&")"
	end if
	
	set rs=server.CreateObject("adodb.recordset")	
	sql="select * from  Dream_Menpiao where Dream_IsOK=true "&typesql&" order by Dream_OrderID desc, id desc"
	rs.open sql,Conn,1,1
	if not(rs.eof and rs.bof) then
	do while not rs.eof
	if rs("Dream_DefaultPicUrl")<>"" then
	Dream_DefaultPicUrl=rs("Dream_DefaultPicUrl")
	else
	Dream_DefaultPicUrl="images/nopic.jpg"
	end if
	url="view.asp?id="&rs("id")
	icompany=icompany&"<dl><dt><a href="""&url&"""><img src="""&Dream_DefaultPicUrl&""" alt="""&rs("Dream_Title")&"""></a></dt><dd><strong title="""&rs("Dream_Title")&""">"&gotTopic(rs("Dream_Title"),30)&"</strong><p><span title=""地址："&rs("Dream_Address")&""">地址："&gotTopic(rs("Dream_Address"),10)&"</span><span title=""电话："&rs("Dream_Phone")&""">电话："&rs("Dream_Phone")&"</span></p></dd></dl>"		
	rs.movenext
	loop	
	end if
	rs.close
	set rs=nothing
	icompany=icompany
end function

sub Pc_Centpage()
	if Page<2 then      
		response.write "<span>上一页</span>"
	else
		response.write "<a href=?page="&Page-1&urlstr&">上一页</a>"
	end if
	if pagecountnum<=9 then
	k=1:j=pagecountnum	
	end if
	if pagecountnum>9 and Page>=6 then
		response.write "<a href=?page=1"&urlstr&">1</a>"
		if Page>6 then
		response.write "<i>…</i>"
		end if
		if pagecountnum-Page>=4 then	
		k=Page-4:j=Page+4
		else
		k=pagecountnum-8:j=pagecountnum
		end if
	end if
	if pagecountnum>9 and Page<6 then
	k=1:j=9	
	end if
	for i=k to j
		if page=i then
		response.write "<a href=?page="&i&urlstr&" class=""a"">"&i&"</a>"
		else
		response.write "<a href=?page="&i&urlstr&">"&i&"</a>"
		end if
		if i>=pagecountnum then
		exit for
		end if
	next
	if pagecountnum-page>=5 and pagecountnum>9 then
		if pagecountnum-page>5 then 
		response.write "<i>…</i>"
		end if
		response.write "<a href=?page="&pagecountnum&urlstr&">"&pagecountnum&"</a>"
	end if
	if pagecountnum-page<1 then
		response.write "<span>下一页</span>"
	else
		response.write "<a href=?page="&Page+1&urlstr&">下一页</a>"
	end if
end sub

function city(AreaID)
	set rsCity=server.CreateObject("adodb.recordset")
	sqlCity="select * from Dream_Area where id="&AreaID
	rsCity.open sqlCity,Conn,1,1
	if not(rsCity.eof and rsCity.bof) then		
	city=rsCity("Dream_Names")
	end if
	rsCity.close
	set rsCity=nothing
end function

function B_ClassName(ThemeID)
	set rsCity=server.CreateObject("adodb.recordset")
	sqlCity="select * from Dream_Theme where id="&ThemeID
	rsCity.open sqlCity,Conn,1,1
	if not(rsCity.eof and rsCity.bof) then		
	B_ClassName=rsCity("Dream_Names")
	end if
	rsCity.close
	set rsCity=nothing
end function



'*************************************************
'函数名：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


'***************************************************
'函数名：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 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

Function ClearHtml(Content,style)

if style<>1 then '1表示不过滤<p></p>标签
Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content)
end if
Content=Zxj_ReplaceHtml("&#[^>]*;", "", Content) 
Content=Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?object[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?param[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?embed[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?table[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml(" ","",Content)
Content=Zxj_ReplaceHtml("　","",Content)
Content=Zxj_ReplaceHtml("&nbsp;","",Content)
Content=Zxj_ReplaceHtml("</?tr[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?st1[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?th[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?td[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?script[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content) 
Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content) 
Content=Zxj_ReplaceHtml("<\\?xml[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("<\/?[a-z]+:[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?font[^>]*>", "", Content) 
Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?h[^>]*>","",Content) 
Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content) 
ClearHtml=Content 
End Function 

Function Zxj_ReplaceHtml(patrn, strng,content) 
IF IsNull(content) Then 
content="" 
End IF 
Set regEx = New RegExp ' 建立正则表达式。 
regEx.Pattern = patrn ' 设置模式。 
regEx.IgnoreCase = true ' 设置忽略字符大小写。 
regEx.Global = True ' 设置全局可用性。 
Zxj_ReplaceHtml=regEx.Replace(content,strng) ' 执行正则匹配 
End Function

Function GetAllImgSrc(ByVal strHtml) 
   Dim rtnStr,Reg,Matches,Match 
   rtnStr = "" 
   IF Not(IsNull(strHtml) Or Len(strHtml)=0) Then 
       Set Reg = New RegExp 
       Reg.Pattern = "<img[^>]+src=""([^"">]+)""[^>]*>" 
       Reg.Ignorecase = True 
       Reg.Global = True 
       Set Matches = Reg.Execute(strHtml) 
       IF Matches.Count > 0 Then 
           For Each Match In Matches 
               'IF Left(Match.SubMatches(0),7) <> "http://" Then 
                   ' 以下返回方式，可以根据你自己的需要，进行修改。 
                   rtnStr = rtnStr & "<div class=""swiper-slide""><img src=""" & Match.SubMatches(0) & """></div>" 
               'End IF 
           Next 
       End IF 
   End IF 
   GetAllImgSrc = rtnStr 
   Set Matches = Nothing 
   Set Regs = Nothing 
End Function

Function GetAllImgSrc_Info(ByVal strHtml) 
   Dim rtnStr,Reg,Matches,Match 
   rtnStr = "" 
   IF Not(IsNull(strHtml) Or Len(strHtml)=0) Then 
       Set Reg = New RegExp 
       Reg.Pattern = "<img[^>]+src=""([^"">]+)""[^>]*>" 
       Reg.Ignorecase = True 
       Reg.Global = True 
       Set Matches = Reg.Execute(strHtml) 
       IF Matches.Count > 0 Then 
           For Each Match In Matches 
              rtnStr = rtnStr & Match.SubMatches(0)
           Next 
       End IF 
   End IF 
   GetAllImgSrc_Info = rtnStr 
   Set Matches = Nothing 
   Set Regs = Nothing 
End Function
%>

