<%
function insertchr(num)
	dim str1:str1 = "├"
	dim str2:str2 = ""
	dim iii
	for iii = 2 to num
		str2 = str2 & "│　"
	next
	insertchr = str2&str1
end function

function gottopic(byval str,byval strlen)
	if str = "" or str = null then
		gottopic = ""
		exit function
	end if
	dim l,t,c,i,tstr
	str = replace(replace(replace(replace(str,"&nbsp;"," "),"&quot;",chr(34)),"&gt;",">"),"&lt;","<")
	l = len(str)
	t = 0
	tstr = str
	strlen = clng(strlen)
	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
			tstr = left(str,i)
			exit for
		end if
	next
	if tstr <> str then
		tstr = tstr & "..."
	end if
	gottopic = replace(replace(replace(replace(tstr," ","&nbsp;"),chr(34),"&quot;"),">","&gt;"),"<","&lt;")
end function

function GetDHTitle(id)
	dim rs,tempstr
	set rs = conn.execute("select title from DH654_URL where id=" & id)
	if not rs.eof then
		tempstr = server.urlencode(rs("title"))
	end if
	rs.close:set rs = nothing
	GetDHTitle = tempstr
end function

function getclasspath(id,table)  '获得路径id(id,"DH654_Class") 
  if id=0 then
     exit function 
  else
	dim rs
	set rs = conn.execute("select parent,ename from "&table&" where id=" & id)
	if not rs.eof then
		getclasspath = getclasspath(rs("parent"),table) &"/"& rs("ename")
	end if
	rs.close:set rs = nothing
  end if  
end function

function GetUrlClassID(id,table)  'id(id,"DH654_URL") 
	dim rs,tempstr
	set rs = conn.execute("select classid from "&table&" where id=" & id)
	if not rs.eof then
		tempstr = rs("classid")
	end if
	rs.close:set rs = nothing
	GetUrlClassID = tempstr
end function

function GetAtoBforT(A,table,B,id)  '自由性强(a,"DH654_URL",b,id) 从表table的B字段id值获得A字段值
	dim rs,tempstr
	set rs = conn.execute("select "&A&" from "&table&" where "&B&"=" & id)
	if not rs.eof then
		tempstr = rs(A)
	end if
	rs.close:set rs = nothing
	GetAtoBforT = tempstr
end function


function GetTopClassID(id,table)  '获得最顶级id(id,"DH654_Class") 
	dim TempHTM
	if id = "" or len(id) = 0 or not isnumeric(id) then
		TempHTM = ""
	else
		dim rs
		set rs = conn.execute("select top 1 id,parent from "&table&" where id=" & id)
		if not rs.eof then
		    if rs("parent")=0 then
		        TempHTM = rs("id")			
		    else
				TempHTM = GetTopClassID(rs("parent"),table)
			end if
		end if
		rs.close:set rs = nothing
	end if
	GetTopClassID = TempHTM
end function

function GetUpClassId(id,table)  '获得上级id(id,"DH654_Class")  
	dim TempHTM
	if id = "" or len(id) = 0 or not isnumeric(id) then
		TempHTM = ""
	else
		dim rs
		set rs = conn.execute("select top 1 id,parent from "&table&" where id=" & id)
		if not rs.eof then
		    TempHTM = rs("parent")			
		end if
		rs.close:set rs = nothing
	end if
	'if TempHTM=0 then TempHTM=id '对只添加大类造成不能生成的bug	
	GetUpClassId = TempHTM
end function


function getclassname(id,table)   '(id,"DH654_Class")  
	dim rs
	set rs = conn.execute("select cname from "&table&"  where id= " & id)
	if not rs.eof then
		getclassname = rs("cname")
	end if
	rs.close:set rs = nothing
end function

function allchildclass(id,table) '获得子类和子子类(id,"DH654_Class")   
   dim rs   
   set rs = conn.execute("select id,parent from "&table&" where parent=" & id)
   while not rs.eof
      allchildclass = allchildclass & "," & rs("id")
      allchildclass = allchildclass & allchildclass(rs("id"),table)
   rs.movenext
   wend
   rs.close:set rs = nothing
end function

function ischildclass(id,table) '判断是否有子类(id,"DH654_Class") 
	dim rs
	set rs = conn.execute("select id from "&table&" where parent=" & id)
	if not rs.eof then
       ischildclass=true
	else
       ischildclass=false
    end if	   
	rs.close:set rs = nothing
end function
	REM 当你在千方百计去掉版权信息时
	REM 是否曾想过自己在失去什么？

function getclassdemo(id,table)   '(id,"DH654_Class")  
	dim rs
	set rs = conn.execute("select ctemp from "&table&" where id= " & id)
	if not rs.eof then
		getclassdemo = rs("ctemp")
	end if
	rs.close:set rs = nothing
end function

function keywords(id,table)   '(id,"DH654_Class")  '获得分类关键词
	dim TempHTM
	if id = "" or len(id) = 0 or not isnumeric(id) then
		TempHTM = ""
	else
		dim rs
		set rs = conn.execute("select top 1 id,keywords from  "&table&" where id=" & id)
		if not rs.eof then
			TempHTM = rs("keywords")
		end if
		rs.close:set rs = nothing
	end if
	keywords = TempHTM
end function

function TitleColor(Title,Num)
   If Not IsNumeric(Num) then Num=0
   If Num=null or Num="" then Num=0  
   dim TempHTM,Box,Max,i
   Box=Split(site_ColorBox,",")
   Max=UBound(Box)  
   If Num<=Max+1 and Num>0 then
	 TitleColor="<font color="""&Box(Num-1)&""">"&Title&"</font>"
   Else
	 TitleColor=Title
   End If
end function
function ColorBox(Num)
   If Not IsNumeric(Num) then Num=0
   If Num=null or Num="" then Num=0
   dim TempHTM,Box,Max,i
   on error resume next
   Box=Split(site_ColorBox,",")
   Max=UBound(Box)  
   TempHTM = "<SELECT name=""titlecolor"">"
   If Num>=Max+1 or Num<=0 then
      TempHTM = TempHTM&"<option style=""background-color:#ffffff;color: #000000"" value=""0"" selected>标题颜色</option>"
   Else
      TempHTM = TempHTM&"<option style=""background-color:#ffffff;color: #000000"" value=""0"">标题颜色</option>"
   End if 
   For i= 0 to Max step 1
       TempHTM = TempHTM&"<option style=""background-color:"&Box(i)&";color: "&Box(i)&""" value="""&i+1&""" "
       if Num=i+1 then TempHTM = TempHTM&"selected"
	   TempHTM = TempHTM&">"&Box(i)&"</option>"
   Next 
   TempHTM = TempHTM&"</SELECT>" 
   ColorBox=TempHTM
end function
function TitleB(Title)
  TitleB="<B>"&Title&"</B>"
end function




%>