<%Function DisplayAnnouncesSplitPages
	Dim ColumnStr
	If DEF_EnableTreeView = 1 Then
		ColumnStr = "TopicSortID"
	Else
		ColumnStr = "ID"
	End If
	Dim RootID,TopicSortID,Temp1
	Dim SQLEndString,Upflag,WhereFlag
	RootID=cCur(Form_RootID)
	TopicSortID = Left(Request.QueryString("TopicSortID"),14)
	If isNumeric(TopicSortID)=0 Then TopicSortID=0
	TopicSortID = cCur(TopicSortID)
	If TopicSortID<0 Then TopicSortID=0
	If TopicSortID=0 Then TopicSortID = Form_TopicSortID
	Dim Rs,SQL
	Dim ALL_FirstTopicSortID,ALL_LastTopicSortID

	Dim ALL_Count
	'SQL = "Select count(*) from LeadBBS_Announce where boardid=" & GBL_board_ID & " and RootIDbak=" & RootID
	'Rs.Open SQL,con,1,1
	'If Not Rs.Eof Then
	'	If isNull(Rs(0)) Then
	'		ALL_Count = 0
	'	Else
	'		ALL_Count = cCur(Rs(0))
	'	End If
	'Else
	'	ALL_Count = 0
	'End If
	'Rs.Close
	All_Count = cCur(LMT_ChildNum)

	If ALL_Count>=DEF_TopicContentMaxListNum Then
		If DEF_EnableTreeView = 1 then
			If DEF_EnableTreeView = 1 Then
				SQL = "Select Top 1 RootIDBak," & ColumnStr & " from LeadBBS_Announce where boardid=" & GBL_board_ID & " and RootIDbak=" & RootID & " Order by TopicSortID"
			Else
				SQL = "Select Top 1 RootIDBak," & ColumnStr & " from LeadBBS_Announce where RootIDbak=" & RootID & " Order by ID"
			End If
			Set Rs = Con.ExeCute(SQL)
			GBL_DBNum = GBL_DBNum + 1
			If Not Rs.Eof Then
				ALL_FirstTopicSortID = cCur(Rs(1))
			Else
				ALL_FirstTopicSortID = 0
			End If
			Rs.Close
			Set Rs = Nothing
	
			If DEF_EnableTreeView = 1 Then
				SQL = "Select max(" & ColumnStr & ") from LeadBBS_Announce where boardid=" & GBL_board_ID & " and RootIDbak=" & RootID
			Else
				SQL = "Select " & ColumnStr & " from LeadBBS_Announce where RootIDbak=" & RootID & " Order by " & ColumnStr & " DESC"
			End If
			Set Rs = Con.ExeCute(SQL)
			GBL_DBNum = GBL_DBNum + 1
			If Not Rs.Eof Then
				If isNull(Rs(0)) Then
					ALL_LastTopicSortID = 0
				Else
					ALL_LastTopicSortID = cCur(Rs(0))
				End If
			Else
				ALL_LastTopicSortID = 0
			End If
			Rs.Close
			Set Rs = Nothing
		Else
			ALL_FirstTopicSortID = Form_RootMinID
			ALL_LastTopicSortID = Form_RootMaxID
		End If
	End If
	

	WhereFlag = 0

	TopicSortID = Left(Request("TopicSortID"),14)
	If isNumeric(TopicSortID)=0 Then TopicSortID=0
	TopicSortID = cCur(TopicSortID)
	'If TopicSortID>ALL_LastTopicSortID Then ALL_LastTopicSortID = ALL_LastTopicSortID-1
	Upflag = Request("Upflag")
	If Upflag<>"1" and Upflag<>"0" Then Upflag="0"
	If Upflag="0" and TopicSortID>=ALL_LastTopicSortID Then TopicSortID = ALL_LastTopicSortID-1
	If Upflag="1" and TopicSortID<=ALL_FirstTopicSortID Then TopicSortID = ALL_FirstTopicSortID+1
	Dim HaveTopicSortIDFlag
	Dim FirstTopicSortID,LastTopicSortID
	Dim GetData
	
	If RootID<>0 Then
		If ALL_Count<DEF_TopicContentMaxListNum Then
			If DEF_EnableTreeView = 1 then
				SQLEndString = " Where boardid=" & GBL_board_ID & " and RootIDBak=" & RootID & " order by " & ColumnStr & " ASC"
			Else
				SQLEndString = " Where RootIDBak=" & RootID & " order by " & ColumnStr & " ASC"
			End If
		Else
			If Upflag="0" Then
				If WhereFlag = 1 Then
					SQLEndString = " where boardid=" & GBL_board_ID
					WhereFlag = 1
					SQLEndString = SQLEndString & " and (RootIDBak=" & RootID & " and " & ColumnStr & ">" & TopicSortID & ")"
				Else
					SQLEndString = SQLEndString & " Where (RootIDBak=" & RootID & " and " & ColumnStr & ">" & TopicSortID & ")"
					WhereFlag = 1
				End If
			Else
				If WhereFlag = 1 Then
					SQLEndString = " where boardid=" & GBL_board_ID
					WhereFlag = 1
					SQLEndString = SQLEndString & " and (RootIDBak=" & RootID & " and " & ColumnStr & "<" & TopicSortID & ")"
				Else
					SQLEndString = SQLEndString & " where (RootIDBak=" & RootID & " and " & ColumnStr & "<" & TopicSortID & ")"
					WhereFlag = 1
				End If
			End If

			If Upflag="0" Then
				SQLEndString = SQLEndString & " order by " & ColumnStr & " ASC"
			Else
				SQLEndString = SQLEndString & " order by " & ColumnStr & " DESC"
			End If
		End If
		SQL = "select top " & DEF_TopicContentMaxListNum & " id,ParentID,ChildNum,Layer,Title,FaceIcon,ndatetime,Hits,Length,UserName,UserID,RootIDbak,TopicSortID,TitleStyle from LeadBBS_Announce " & SQLEndString
		Set Rs = Con.ExeCute(SQL)
		GBL_DBNum = GBL_DBNum + 1
		If Not Rs.Eof Then
			HaveTopicSortIDFlag = 1
			GetData = Rs.GetRows(-1)
		Else
			HaveTopicSortIDFlag = 0
		End If
		Rs.Close
		Set Rs = Nothing
	Else
		HaveTopicSortIDFlag = 0
	End If

	If HaveTopicSortIDFlag = 1 Then
		Temp1 = Ubound(GetData,2)
		If DEF_EnableTreeView = 1 Then
			FirstTopicSortID = cCur(GetData(12,0))
			LastTopicSortID = cCur(GetData(12,Temp1))
		Else
			FirstTopicSortID = cCur(GetData(0,0))
			LastTopicSortID = cCur(GetData(0,Temp1))
		End If

		If FirstTopicSortID>LastTopicSortID Then
			SQL = LastTopicSortID
			LastTopicSortID = FirstTopicSortID
			FirstTopicSortID = SQL
		End If
	Else
		Temp1 = 0
	End If
	
	If ALL_Count>=DEF_TopicContentMaxListNum Then
	SQL = "?BoardID=" & GBL_board_ID
	If Form_ParentID<>0 Then SQL = SQL & "&ID=" & Form_ParentID
	Dim PageSplitString
	PageSplitString = "<tr bgcolor=" & DEF_BBS_LightestColor & " height=25 class=TBBG9><td colspan=5><img src=" & DEF_BBS_HomeUrl & "images/null.gif width=2 height=3><br>&nbsp;"
	If FirstTopicSortID<=ALL_FirstTopicSortID Then
		PageSplitString = PageSplitString & "<font color=888888 class=GrayFont>首页</font>"
		PageSplitString = PageSplitString & " <font color=888888 class=GrayFont>上页</font>"
	Else
		PageSplitString = PageSplitString & "<a href=announce2.asp" & SQL & ">首页</a>"
		PageSplitString = PageSplitString & " <a href=announce2.asp" & SQL & "&RootID=" & RootID & "&TopicSortID=" & FirstTopicSortID & "&Upflag=1>上页</a>"
	End If

	If LastTopicSortID>=ALL_LastTopicSortID Then
		PageSplitString = PageSplitString & " <font color=888888 class=GrayFont>下页</font>"
		PageSplitString = PageSplitString & " <font color=888888 class=GrayFont>尾页</font>"
	Else
		PageSplitString = PageSplitString & " <a href=announce2.asp" & SQL & "&RootID=" & RootID & "&TopicSortID=" & LastTopicSortID & ">下页</a>"
		PageSplitString = PageSplitString & " <a href=announce2.asp" & SQL & "&Upflag=1&TopicSortID=" & ALL_LastTopicSortID+1 & ">尾页</a>"
	End If
	Rs = Temp1
	If HaveTopicSortIDFlag = 1 Then Rs = Rs+1
	PageSplitString = PageSplitString & " 相关帖共有<b>" & ALL_Count &"</b>帖 此页<b>" & Rs & "</b>帖 每页<b>" & DEF_TopicContentMaxListNum & "</b>帖"
	PageSplitString = PageSplitString & "</td></tr>"
	End If

	Dim For1,For2,StepValue

	Response.Write "<table width=332 border=0 cellspacing=0 cellpadding=0 style='table-layout:fixed; word-break:break-all'><tr><td><img src=../images/" & GBL_DefineImage & "signature.gif width=500 height=17 border=0></td></tr></table>"
	%>
	<table width="100%" border="0" cellspacing="1" cellpadding="3" align="center">
	<%
	If HaveTopicSortIDFlag = 1 Then
		Response.Write "<tr><td><b>相关帖子</b></td><tr>"
		If Upflag="0" Then
			For1 = 0
			For2 = Temp1
			StepValue = 1
		Else
			For1 = Temp1
			For2 = 0
			StepValue = -1
		End If
		DisplayAnnounceData For1,For2,StepValue,GetData
		Response.Write PageSplitString
	End If
	Response.Write "</table>"

	Set Rs = Nothing

End Function

Function DisplayAnnounceData(For1,For2,StepValue,GetData)

	Dim N,Temp,SQL
	SQL = "?BoardID=" & GBL_board_ID
	'If Form_ParentID<>0 Then SQL = SQL & "&ID=" & Form_ParentID
	'id,ParentID,ChildNum,Layer,Title,FaceIcon,ndatetime,Hits,Length,UserName,UserID
	For N = For1 to For2 Step StepValue
		Response.Write "<tr><td align=left>"
		
		If GetData(3,N)>DEF_BBS_MaxLayer Then GetData(3,N)=10
		If DEF_EnableTreeView = 1 Then
			Response.Write Replace(string((GetData(3,N)-1),"-"),"-","&nbsp; &nbsp; ")
		Else
			If cCur(GetData(1,n)) <> 0 then Response.Write "&nbsp; &nbsp; "
		End If
		If cCur(GetData(11,N))>=DEF_BBS_TOPMinID And cCur(GetData(1,N))=0 Then
			Response.Write "<img src=" & DEF_BBS_HomeUrl & "images/" & GBL_DefineImage & "intop.gif align=absbottom width=15> "
		Else
			Response.Write "<img src=" & DEF_BBS_HomeUrl & "images/" & GBL_DefineImage & "bf/face" & GetData(5,N) & ".gif align=absbottom width=20 height=20> "
		End If
		If Left(GetData(4,n),3) = "re:" Then GetData(4,n) = Mid(GetData(4,n),4)
		If Form_ParentID<>cCur(GetData(0,N)) Then
			Response.Write " <a href=" & DEF_BBS_HomeUrl & "Announce/announce2.asp" & SQL & "&ID=" & GetData(0,N) & "&TopicSortID=" & GetData(12,N) & ">"
			'Response.Write htmlencode(GetData(4,N))
			If GetData(13,n) <> 1 and strLength(GetData(4,N))>DEF_BBS_DisplayTopicLength Then GetData(4,N) = LeftTrue(GetData(4,N),DEF_BBS_DisplayTopicLength-3) & "..."
			If GetData(13,n) >=60 Then
				GetData(4,n) = "<font color=gray class=GrayFont>帖子等待审核中...</font>"
				GetData(13,n) = 1
			End If
			Response.Write DisplayAnnounceTitle(GetData(4,n),GetData(13,n))
			Response.Write "</a>"
		Else
			Response.Write "<font color=55555>"
			If GetData(13,n) <> 1 and strLength(GetData(4,N))>DEF_BBS_DisplayTopicLength Then GetData(4,N) = LeftTrue(GetData(4,N),DEF_BBS_DisplayTopicLength-3) & "..."
			If GetData(13,n) >=60 Then
				GetData(4,n) = "<font color=gray class=GrayFont>帖子等待审核中...</font>"
				GetData(13,n) = 1
			End If
			Response.Write DisplayAnnounceTitle(GetData(4,n),GetData(13,n))
			Response.Write "</font>"
		End If
		If cCur(GetData(10,N)) > 0 Then
			Response.Write " (<a href=" & DEF_BBS_HomeUrl & "User/LookUserInfo.asp?ID=" & GetData(10,N) & ">" & htmlencode(GetData(9,N)) & "</a>,"
		Else
			Response.Write " (" & htmlencode(GetData(9,N)) & ","
		End If
		Response.Write GetData(7,N) & ","
		Temp = RestoreTime(GetData(6,N))
		If DateDiff("d",Temp,DEF_Now)<1 Then Response.Write " <font color=990000 class=RedFont>"
		Response.Write Temp & ")</td></tr>"
	Next

End Function
%>