<%

	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''' 处理 C 型 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''





	sub QuaryChild()
		dim rs_RecCount, rSub_RecCount, Sch_Ver
		dim iColumns()

		if HomeCurrVer = "CN" or HomeCurrVer = "" then	'中文版本
			Sch_Ver = "CN"
		elseif HomeCurrVer = "EN" then	'英文版本
			Sch_Ver = "EN"
		end if

		set r2 = server.createobject("adodb.recordset")

		'搜索 含有一级子栏目 的双亲栏目编号
		sqlc = "select distinct MyColumn from [column] " &_
			"where isUse=(1) and ParentId=0 and name='" & CurrCom & "' order by MyColumn asc"

		rs.open sqlc,conn,1,1
		if not (rs.eof or rs.bof) then
			rs_RecCount = rs.RecordCount
			Redim Preserve iColumns(rs_RecCount)	'这个数组暂时是多余的，等着以后用吧
			rs.movefirst
			for i = 1 to rs_RecCount
				iColumns(i) = rs(0)
				rs.movenext
			next
		else
			rs_RecCount = 0
		end if
		rs.close


		'########################################################################################
		for n = 1 to rs_RecCount '栏目
			ThisColumn = iColumns(n)
			'Columns(n) = ThisColumn
			sql1 = "select ID, ParentId, CN, EN from [column] " &_
				"where isUse=(1) and ParentId=0 and name='" & CurrCom & "' " &_
				"and MyColumn=" & ThisColumn
			rSub.open sql1,conn,1,1 '检索指定一级子菜单
			rSub_RecCount = rSub.RecordCount
				'========================================================================
				for i = 1 to rSub_RecCount
					MyParent = rSub(0)
					ReDim Preserve mu(i)	'@@@@@@@@@ 新的一级二级菜单临时数组
					ThisMenu1 = rSub(Sch_Ver)
					mu(i) = ThisMenu1 & "~" & MyParent

					'找出我的二级孩子，即：ParentId=我的ID
					sql2 = "select ID, ParentId, CN, EN from [column] " &_
						"where isUse=(1) and ParentId=" & MyParent
					r2.open sql2,conn,1,1 '二级子菜单
					'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
					do while not r2.eof
						ThisMenu2 = r2(Sch_Ver)
						mu(i) = mu(i) & "|" & ThisMenu2 & "~" & r2("ID")
					r2.movenext
					loop
					'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
					r2.close

				rSub.movenext
				next
				'========================================================================
			rSub.close

			'制作子菜单
			'------------------------
			call MakeChildMenu( ThisColumn )

		next
		'########################################################################################

		set r2 = nothing
	end sub







	'接收 mu(i) 数组的内容，制作子菜单	用 CSS 控制菜单外观
	'--------------------------------------------------------------------------------
	sub MakeChildMenu( m )
		'm 为栏目编号
		dim MuTmp	'临时变量
		dim ChildTmp	'临时变量
		dim ArrChild	'再次披开子菜单
		dim Arr		'栏目名和连接 ID

		'中文~15|中1~17|中2~18


		response.write "" &_
			"<script language=""JavaScript"">" &_
			"	NowLoading( true, ""系统正在装载栏目子菜单 " & m & "，请稍候..."" );" &_
			"</script>"

		response.write "" &_
			"<div " &_
			"class=""ChildMenu"" " &_
			"id=""ChildMenu0" & m & """ " &_
			"style=""display:none"" " &_
			"onmouseover=""ShowChildMenu( ChildMenu0" & m & ", false );"" " &_
			"onmouseout=""HideChildMenu( ChildMenu0" & m & " );"" " &_
			">" &_
			"<center>" &_
			"<TABLE border=0 cellspacing=1 cellpadding=0 class=""ChildTable"">" &_
			"  <tbody>" &_
			"  <TR>" &_
			"    <td class=""ChildTD"" width=""100%"">"

		dim CurrVerRequest
		if HomeCurrVer = "CN" or HomeCurrVer = "" then	'中文版本
			CurrVerRequest = ""
		elseif HomeCurrVer = "EN" then		'英文版本	
			CurrVerRequest = "ver=EN&"
		end if

		dim ChildNum
		ChildNum = 0
		for x = 0 to ubound(mu)
			if mu(x) <> "" then
				MuTmp = mu(x)
				ArrChild = split( MuTmp,"|" )
				ChildTmp = ArrChild(0)
				Arr = split(ChildTmp,"~")
				if ChildNum<>0 then
					response.write "<br>"
				end if
				response.write "&nbsp;" &_
					"<a href=""column" & m & ".asp?" & CurrVerRequest & "ColumnID=" & Arr(1) & """" &_
					"  class=ChildTitle>" & Arr(0) & "</a>"
				if ubound(ArrChild)>=1 then
					for y = 1 to ubound(ArrChild)
						ChildTmp = ArrChild(y)
						Arr = split(ChildTmp,"~")
						response.write "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" &_
							"<font class=TitleList>■</font> " &_
							"<a href=""column" & m & ".asp?" & CurrVerRequest & "ColumnID=" & Arr(1) & """ class=ChildTitle>" &_
							Arr(0) & "</a>"
					next
				end if
				ChildNum = ChildNum + 1
			end if
		next

		response.write "" &_
			"    </td>" &_
			"  </tr>" &_
			"  </tbody>" &_
			"</table>" &_
			"</center>" &_
			"</div>"

	end sub





	sub MakeProductChildMenu()

		response.write "" &_
			"<script language=""JavaScript"">" &_
			"	IsAdvanceVer = true;" &_
			"	NowLoading( true, ""系统正在装载产品分类菜单，请稍候..."" );" &_
			"</script>"

		response.write "" &_
			"<div " &_
			"class=""ChildMenu"" " &_
			"id=""ProductChildMenu"" " &_
			"style=""display:none"" " &_
			"onmouseover=""ShowChildMenu( ProductChildMenu, false );"" " &_
			"onmouseout=""HideChildMenu( ProductChildMenu );"" " &_
			">" &_
			"<center>" &_
			"<TABLE border=0 cellspacing=1 cellpadding=0 class=""ChildTable"">" &_
			"  <tbody>" &_
			"  <TR>" &_
			"    <td class=""ChildTD"" width=""100%"">"

		dim psql
		dim ChildNum
		ChildNum = 0

		set rsp = server.createobject("adodb.recordset")
		psql = "select distinct PSort from [product] " &_
			"where name='" & CurrCom & "' and ver='" & HomeCurrVer & "'"
		rsp.open psql,conn,1,1
		if rsp.eof or rsp.bof then
			response.write "&nbsp;暂时还没有任何分类"
		end if
		do while not rsp.eof
			if ChildNum<>0 then
				response.write "<br>"
			end if
			if trim(rsp(0))<>"" then
				response.write "&nbsp;" &_
					"<a href=""product.asp?sort=" & rsp(0) & "&ver=" & HomeCurrVer & """ " &_
					"class=ChildTitle>" & rsp(0) & "</a>"
				ChildNum = ChildNum + 1
			end if
			rsp.movenext
		loop
		rsp.close
		set rsp = nothing

		response.write "" &_
			"    </td>" &_
			"  </tr>" &_
			"  </tbody>" &_
			"</table>" &_
			"</center>" &_
			"</div>"

	end sub





	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''' 处理 D 型 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
	''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''





	sub Process_D_Menu( HomeMenuStr, HomeMenu )
		dim rs_RecCount, rSub_RecCount, Sch_Ver
		'处理左边的版本显示文字问题
		dim strLeftMemLoginTitle, strLeftMemLoginSubmit, strLeftMemLoginReg, strLeftNewsListTitle, strLeftLinks
		strLeftMemLoginTitle = "用户登陆"
		strLeftMemLoginSubmit = "登陆"
		strLeftMemLoginReg = "注册"
		strLeftLinks = "友情链接"

		if HomeCurrVer = "CN" or HomeCurrVer = "" then	'中文版本
			Sch_Ver = "CN"
		elseif HomeCurrVer = "EN" then	'英文版本
			Sch_Ver = "EN"
			strLeftMemLoginTitle = "members log in"
			strLeftMemLoginSubmit = "Login"
			strLeftMemLoginReg = "sign up"
			strLeftLinks = "Links"
		end if

		dim ArrHomeMenu		'intro|product|news|order|job|manage|column1|column4|contactus
		dim ArrHomeMenuStr	'公司简介|产品介绍|公司新闻|查看定单|招聘信息|网站维护|友情链接|中日友好|联系方式
		dim i, n, lngArr	'lngArr=数组的长度, n用在检索二级栏目
		dim mtmp, tmpc, tmpcStr, ThisColumn	'mtmp 是存放 ArrHomeMenu 数组的临时变量
		dim finArrMenu(), finArrMenuStr(), finIsHasKey()	'预定成品数组
		dim MyParent

		HomeMenuStr = replace( HomeMenuStr," ","&nbsp;" )
		ArrHomeMenuStr = split( HomeMenuStr, "|" )
		ArrHomeMenu = split( HomeMenu, "|" )

		lngArr = ubound(ArrHomeMenu)	'获取数组的长度

		Redim preserve finArrMenu(lngArr)
		Redim preserve finArrMenuStr(lngArr)
		Redim preserve finIsHasKey(lngArr)

		set rsp = server.createobject("adodb.recordset")
		for i=0 to lngArr
			finIsHasKey(i) = "false"	'有没有子菜单 1=true, 0=false
			mtmp = Lcase(ArrHomeMenu(i))
			tmpc = "" :: tmpcStr = ""

			if mtmp = "news" then	'非菜单处理，左边条条新闻版本显示问题处理
				strLeftNewsListTitle = ArrHomeMenuStr(i)
			end if
			if mtmp = "product" then	'处理产品菜单
				sql = "select distinct PSort from [product] " &_
					"where name='" & CurrCom & "' and ver='" & HomeCurrVer & "'"
				rsp.open sql,conn,1,1
				if not rsp.eof then
					finIsHasKey(i) = "true"
					do while not rsp.eof
						if trim(rsp(0))<>"" then
							tmpc = tmpc &_
								"product.asp?sort=" & rsp(0) & "&ver=" & Sch_Ver & "||"
							tmpcStr = tmpcStr & rsp(0) & "||"
						end if
					rsp.movenext
					loop
				end if
				rsp.close
			end if
			if Left(mtmp,6) = "column" then	'处理子栏目
				if len(mtmp)=8 then
					ThisColumn = right(mtmp,2)
				elseif len(mtmp)=7 then
					ThisColumn = right(mtmp,1)
				end if
				sql1 = "select ID, ParentId, CN, EN from [column] " &_
					"where isUse=(1) and ParentId=0 and name='" & CurrCom & "' " &_
					"and MyColumn=" & ThisColumn
				rSub.open sql1,conn,1,1 '检索指定一级子菜单
				rSub_RecCount = rSub.RecordCount
				if rSub_RecCount > 0 then
					finIsHasKey(i) = "true"	'有没有子菜单 1=true, 0=false
				end if
				'========================================================================
				for n = 1 to rSub_RecCount
					MyParent = rSub(0)
					tmpc = tmpc & mtmp & ".asp?ver=" & Sch_Ver & "&ColumnID=" & rSub(0)
					tmpcStr = tmpcStr & rSub(Sch_Ver)

					'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
					sql2 = "select ID, CN, EN from [column] " &_
						"where isUse=(1) and ParentId=" & MyParent
					rsp.open sql2,conn,1,1	'二级子菜单（找出我的二级孩子，即：ParentId=我的ID）
					do while not rsp.eof
						tmpc = tmpc & "**" & mtmp & ".asp?ver=" & Sch_Ver & "&ColumnID=" & rsp(0)
						tmpcStr = tmpcStr & "**" & rsp(Sch_Ver)
					rsp.movenext
					loop
					rsp.close
					'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

					tmpc = tmpc & "||"
					tmpcStr = tmpcStr & "||"
				rSub.movenext
				next
				'========================================================================
				rSub.close
			end if

			if tmpc<>"" and tmpcStr<>"" then
				if len(tmpc)>2 and len(tmpcStr)>2 then
					tmpc=left(tmpc,len(tmpc)-2) :: tmpcStr=left(tmpcStr,len(tmpcStr)-2)
				end if
			end if

			tmpcStr = replace( tmpcStr," ","&nbsp;" )
			finArrMenu(i) = tmpc
			finArrMenuStr(i) = tmpcStr
		next
		set rsp = nothing


		''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		response.write "<script language=""JavaScript"">" & VbCrlf &_
		"	var ArrHomeMenu = new Array(" & lngArr+1 & ");" & VbCrlf &_
		"	var ArrHomeMenuStr = new Array(" & lngArr+1 & ");" & VbCrlf &_
		"	var ArrMenu = new Array(" & lngArr+1 & ");" & VbCrlf &_
		"	var ArrMenuStr = new Array(" & lngArr+1 & ");" & VbCrlf &_
		"	var IsHasKey = new Array(" & lngArr+1 & ");" & VbCrlf & VbCrlf &_
		"	var strLeftMemLoginTitle = """ & strLeftMemLoginTitle & """;" & VbCrlf &_
		"	var strLeftMemLoginSubmit = """ & strLeftMemLoginSubmit & """;" & VbCrlf &_
		"	var strLeftMemLoginReg = """ & strLeftMemLoginReg & """;" & VbCrlf &_
		"	var strLeftNewsListTitle = """ & strLeftNewsListTitle & """;" & VbCrlf &_
		"	var strLeftLinks = """ & strLeftLinks & """;" & VbCrlf & VbCrlf

		for i=0 to lngArr
			tmpc = ArrHomeMenu(i)
			if Lcase(tmpc) = "edefault" then
				tmpc = "intro.asp?ver=EN"
				if Lcase(Sch_Ver) = "en" then
					tmpc = "intro.asp?ver=CN"
				end if
			else
				tmpc = tmpc & ".asp?ver=" & Sch_Ver
			end if
			response.write "" &_
			"	ArrHomeMenu[" & i & "]=""" & tmpc & """;" & VbCrlf &_
			"	ArrHomeMenuStr[" & i & "]=""" & ArrHomeMenuStr(i) & """;" & VbCrlf &_
			"	ArrMenu[" & i & "]=""" & finArrMenu(i) & """;" & VbCrlf &_
			"	ArrMenuStr[" & i & "]=""" & finArrMenuStr(i) & """;" & VbCrlf &_
			"	IsHasKey[" & i & "]=" & finIsHasKey(i) & ";" & VbCrlf & VbCrlf
		next

		response.write "</script>" & VbCrlf

	end sub
%>