<%
'#################################################################################
'## Copyright (C) 2000  Michael Anderson
'## 
'## This program is free software; you can redistribute it and/or
'## modify it under the terms of the GNU General Public License
'## as published by the Free Software Foundation; either version 2
'## of the License, or any later version.
'##
'## All copyright notices regarding Snitz Forums 2000
'## must remain intact in the scripts and in the outputted HTML
'## The "powered by" text/logo with a link back to 
'## http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet.
'## 
'## This program is distributed in the hope that it will be useful,
'## but WITHOUT ANY WARRANTY; without even the implied warranty of
'## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'## GNU General Public License for more details.
'## 
'## You should have received a copy of the GNU General Public License
'## along with this program; if not, write to the Free Software
'## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
'## 
'## Support can be obtained from support forums at:
'## http://forum.snitz.com 
'##
'## Correspondence and Marketing Questions can be sent to:
'## reinhold@bigfoot.com
'## 
'## or
'## 
'## Snitz Communications 
'## C/O: Michael Anderson
'## PO Box 200
'## Harpswell, ME 04079
'#################################################################################
%>
<!--#INCLUDE FILE="config.asp" -->
<!--#INCLUDE FILE="inc_functions.asp" -->
<!--#INCLUDE FILE="inc_top.asp" -->
<%
	strDBNTUserName = Request.Cookies(strCookieURL & "User")("Name")
	if strAuthType = "nt" then
		strDBNTUserName = Session(strCookieURL & "userID")
	end if
if IsEmpty(Session(strCookieURL & "last_here_date")) then
	Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTUserName)
end if

if strShowStatistics <> "1" then

	set rs1 = Server.CreateObject("ADODB.Recordset")

	'## Forum_SQL
	strSql = "SELECT " & strTablePrefix & "TOTALS.P_COUNT, " & strTablePrefix & "TOTALS.T_COUNT, " & strTablePrefix & "TOTALS.U_COUNT "
	strSql = strSql & " FROM " & strTablePrefix & "TOTALS"

	rs1.open strSql, my_Conn

	Users = rs1("U_COUNT")
	Topics = rs1("T_COUNT")
	Posts = rs1("P_COUNT")

	rs1.Close
	set rs1 = nothing
end if

'## Forum_SQL - Get all Forums From DB
strSql = "SELECT " & strTablePrefix & "CATEGORY.CAT_ID, " & strTablePrefix & "CATEGORY.CAT_STATUS, " 
strSql = strSql & strTablePrefix & "CATEGORY.CAT_NAME "
strSql = strSql & " FROM " & strTablePrefix & "CATEGORY "
strSql = strSql & " ORDER BY " & strTablePrefix & "CATEGORY.CAT_NAME ASC;"

set rs = my_Conn.Execute (strSql)
%>

<table border=0 width="95%" cellspacing=0 cellpadding=0 align=center>

  <tr>
	<td>
	<%
		ShowLastHere = (cint(ChkUser2(strDBNTUserName, Request.Cookies(strCookieURL & "User")("Pword"))) > 0)
		if strShowStatistics <> "1" then
			%>
	    <table width="100%" border="0">
			<tr>
			<td>
			<% if ShowLasthere then %>
			<font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">
			You Last Visited - <% =ChkDate(Session(strCookieURL & "last_here_date")) %> <% =ChkTime(Session(strCookieURL & "last_here_date")) %>
			</font>
			<%else%>
			&nbsp;
			<%end if%>
			</td>
			<td align=right><font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">There are <% =Posts %> Posts in <% =Topics %> Topics and <% =Users %> Users&nbsp;&nbsp;</font></td>
			</tr>
		</table>
		<%
		else
			Response.Write("&nbsp;&nbsp;")
		end if
		%>
	</td>  
  </tr>

  <tr>
    <td bgcolor="<% =strTableBorderColor %>">
    <table border=0 width="100%" cellspacing=1 cellpadding=4>
      <tr>
        <td align=center bgcolor="<% =strHeadCellColor %>" nowrap valign="top"><b>&nbsp;</td>
        <td align=center bgcolor="<% =strHeadCellColor %>" nowrap valign="top"><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">Forum</font></b></td>
        <td align=center bgcolor="<% =strHeadCellColor %>" nowrap valign="top"><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">Topics</font></b></td>
        <td align=center bgcolor="<% =strHeadCellColor %>" nowrap valign="top"><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">Posts</font></b></td>
        <td align=center bgcolor="<% =strHeadCellColor %>" nowrap valign="top"><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">Last&nbsp;Post</font></b></td>
<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then %>
        <td align=center bgcolor="<% =strHeadCellColor %>" nowrap valign="top"><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strHeadFontColor %>">Moderator(s)</font></b></td>
<% end if 
 if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td align=center bgcolor="<% =strHeadCellColor %>">
        <% PostingOptions() %>
        </td>
<% end if %>
      </tr>
<% if rs.EOF or rs.BOF then %>
      <tr>
        <td bgcolor="<% =strCategoryCellColor %>" colspan="<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then Response.Write("6") else Response.Write("5")%>"><font face="<% =strDefaultFontFace %>" color="<% =strCategoryFontColor %>" size="<% =strDefaultFontSize %>" valign="top"><b>No Categories/Forums Found</b></font></td>
<%	if (mlev = 4 or mlev = 3) then %>
        <td bgcolor="<% =strCategoryCellColor %>"><font face="<% =strDefaultFontFace %>" color="<% =strCategoryFontColor %>" size="<% =strDefaultFontSize %>" valign="top">&nbsp;</font></td>
<%	end if %>
      </tr>
<% else
      intPostCount  = 0
      intTopicCount = 0
      intForumCount = 0
      strLastPostDate = ""
	do until rs.EOF 

		'## Forum_SQL - Build SQL to get forums via category
		strSql = "SELECT " & strTablePrefix & "FORUM.FORUM_ID, " 
		strSql = strSql & strTablePrefix & "FORUM.F_STATUS, " 
		strSql = strSql & strTablePrefix & "FORUM.CAT_ID, " 
		strSql = strSql & strTablePrefix & "FORUM.F_SUBJECT, " 
		strSql = strSql & strTablePrefix & "FORUM.F_URL, " 
		strSql = strSql & strTablePrefix & "FORUM.F_DESCRIPTION, " 
		strSql = strSql & strTablePrefix & "FORUM.CAT_ID, " 
		strSql = strSql & strTablePrefix & "FORUM.F_TOPICS, " 
		strSql = strSql & strTablePrefix & "FORUM.F_COUNT, " 
		strSql = strSql & strTablePrefix & "FORUM.F_LAST_POST, " 
		strSql = strSql & strTablePrefix & "FORUM.F_STATUS, " 
		strSql = strSql & strTablePrefix & "FORUM.F_TYPE,  " 
		strSql = strSql & strTablePrefix & "FORUM.F_PRIVATEFORUMS,  " 
		strSql = strSql & strMemberTablePrefix & "MEMBERS.MEMBER_ID, " 
        strSql = strSql & strMemberTablePrefix & "MEMBERS.M_NAME " 
        strSql = strSql & "FROM " & strTablePrefix & "FORUM " 
		strSql = strSql & "LEFT JOIN " & strMemberTablePrefix & "MEMBERS ON "
		strSql = strSql & strTablePrefix & "FORUM.F_LAST_POST_AUTHOR = "
		strSql = strSql & strMemberTablePrefix & "MEMBERS.MEMBER_ID "
		strSql = strSql & " WHERE " & strTablePrefix & "FORUM.CAT_ID = " & rs("CAT_ID") & " "
		strSql = strSql & " ORDER BY " & strTablePrefix & "FORUM.F_SUBJECT ASC;"

		set rsForum =  my_Conn.Execute (strSql)
		
		chkDisplayHeader = true
		 
		if rsForum.eof or rsForum.bof then
%>

      <tr>
        <td bgcolor="<% =strCategoryCellColor %>" colspan="<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then Response.Write("6") else Response.Write("5") end if%>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strCategoryFontColor %>" valign="top"><b><% =ChkString(rs("CAT_NAME"),"display") %></b></font></td>
<%		if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td bgcolor="<% =strCategoryCellColor %>" align=center valign=top nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
        <% call CategoryAdminOptions() %>
        </font></b></td>
<%		end if %>
      </tr>

<%
			Response.Write "  <tr>" & vbCrLf
			Response.Write "    <td bgcolor=""" & strForumCellColor & """ colspan="
			if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then 
				Response.Write """6""" 
			else 
				Response.Write """5"""
			end if
			Response.Write "><font face=""" & strDefaultFontFace & """ color=""" & strForumFontColor & """ size=""" & strDefaultFontSize & """><b>No Forums Found</b></font></td>" & vbCrLf
			if (mlev = 4 or mlev = 3) then
				Response.Write "    <td bgcolor=""" & strForumCellColor & """><font face=""" & strDefaultFontFace & """ color=""" & strForumFontColor & """ size=""" & strDefaultFontSize & """>&nbsp;</font></td>" & vbCrLf
			end if
			Response.Write "  </tr>" & vbCrLf
		else
			blnHiddenForums = false
			do until rsForum.Eof
				if ChkDisplayForum(rsForum("FORUM_ID")) then
					if rsForum("F_TYPE") <> "1" then 
						intPostCount  = intPostCount + rsForum("F_COUNT")
						intTopicCount = intTopicCount + rsForum("F_TOPICS")
						intForumCount = intForumCount + 1
						if rsForum("F_LAST_POST") > strLastPostDate then 
							strLastPostDate = rsForum("F_LAST_POST")
							intLastPostForum_ID = rsForum("FORUM_ID")
						end if
					end if
				
					if chkDisplayHeader then
%>

      <tr>
        <td bgcolor="<% =strCategoryCellColor %>" colspan="<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then Response.Write("6") else Response.Write("5") end if%>" valign="top"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strCategoryFontColor %>" ><b><% =ChkString(rs("CAT_NAME"),"display") %></b></font></td>
<%		if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td bgcolor="<% =strCategoryCellColor %>" align=center valign=top nowrap><b><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
        <% call CategoryAdminOptions() %>
        </font></b></td>
<%		end if %>
      </tr>

<%
						chkDisplayHeader = false
					end if
%>
      <tr>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top>
<%					if rsForum("F_TYPE") = 0 then
						if rs("CAT_STATUS") = 0 then 
							%><a href="forum.asp?FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><%
								if rsForum("F_LAST_POST") > Session(strCookieURL & "last_here_date") then
									Response.Write "<img src=""icon_folder_new_locked.gif"" height=15 width=15 border=0 hspace=0 alt=""Category Locked""></a>"
								else
									Response.Write "<img src=""icon_folder_locked.gif"" height=15 width=15 border=0 hspace=0 alt=""Category Locked""></a>"
								end if     
						else 
							if rsForum("F_STATUS") <> 0 then 
								%><a href="forum.asp?FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><% =ChkIsNew(rsForum("F_LAST_POST")) %></a><%
							else
								%><a href="forum.asp?FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><%
								if rsForum("F_LAST_POST") > Session(strCookieURL & "last_here_date") then
									Response.Write "<img src=""icon_folder_new_locked.gif"" height=15 width=15 border=0 hspace=0 alt=""Forum Locked""></a>"
								else
									Response.Write "<img src=""icon_folder_locked.gif"" height=15 width=15 border=0 hspace=0 alt=""Forum Locked""></a>"
								end if
							end if
						end if
					else 
						if  rsForum("F_TYPE") = 1 then 
							%>          <a href="<% =rsForum("F_URL")& """ target=""_blank" %>"><img src="icon_url.gif" height=16 width=16 border=0 hspace=0></a><%
						end if
					end if %>
        </td>
        <td<% if rsForum("F_TYPE") = 1 then Response.Write(" colspan=4") %> bgcolor="<% =strForumCellColor %>" valign="top">
	  <font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><a href="<% if rsForum("F_TYPE") = 0 then Response.Write("forum.asp?FORUM_ID=" & rsForum("FORUM_ID") & "&CAT_ID=" & rsForum("CAT_ID") & "&Forum_Title=" & ChkString(rsForum("F_SUBJECT"),"urlpath")) else if rsForum("F_TYPE") = 1 then Response.Write(rsForum("F_URL") & """ target=""_blank") end if %>"><% =ChkString(rsForum("F_SUBJECT"),"display") %></a><br>
        <font color="<% =strForumFontColor %>" face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">
        <% = rsForum("F_DESCRIPTION") %>
        </font></td>
<%					if rsForum("F_TYPE") = 0 then
						if IsNull(rsForum("F_TOPICS")) then %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>">0</font></td>
<%						else %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>"><% =rsForum("F_TOPICS") %></font></td>
<%						end if 
						if IsNull(rsForum("F_COUNT")) then %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>">0</font></td>
<%						else %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>"><% =rsForum("F_COUNT") %></font></td>
<%						end if 
		if IsNull(rsForum("MEMBER_ID")) then
            strLastUser = ""
        else
            strLastUser = "<br>by: " 
            if strUseExtendedProfile then
				strLastUser = strLastUser & "<a href=""pop_profile.asp?mode=display&id="& RsForum("MEMBER_ID") & """>"
			else
				strLastUser = strLastUser & "<a href=""JavaScript:openWindow2('pop_profile.asp?mode=display&id=" & rsForum("MEMBER_ID") & "')"">"
			end if
            strLastUser = strLastUser & rsForum("M_NAME") & "</a>"
        end if
%>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top nowrap><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strFooterFontSize %>"><b><% =ChkDate(rsForum("F_LAST_POST")) %></b><br>
        <% =ChkTime(rsForum("F_LAST_POST")) %><%= strLastUser%></font></td>
<%					else 
						if rsForum("F_TYPE") = 1 then 
					'## Do Nothing 
						end if 
					end if 
					if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then %>
        <td bgcolor="<% =strForumCellColor %>" align=left valign=top><font face="<% =strDefaultFontFace %>" color="<% =strForumFontColor %>" size="<% =strDefaultFontSize %>">
	<% if (listForumModerators(rsForum("FORUM_ID")) <> "") then Response.Write(listForumModerators(rsForum("FORUM_ID"))) else Response.Write("&nbsp;") end if %></font></td>
<%					end if 
					if (mlev = 4 or mlev = 3) or (lcase(strNoCookies) = "1") then %>
        <td bgcolor="<% =strForumCellColor %>" align=center valign=top nowrap>
        <% call ForumAdminOptions %>
        </td>
<%					end if %>
      </tr>
<%
				else
					blnHiddenForums = true
				end if ' ChkDisplayForum() 
				rsForum.MoveNext
			loop
		end if
		rs.MoveNext
	loop
 end if 
if strShowStatistics = "1" then
	WriteStatistics
end if %>
    </table>           
    </td>
  </tr>
<tr>
	<td>
		<table width="100%">
		<tr>
			<td>
			<font face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">
			<img alt="New Posts" src="icon_folder_new.gif" width=8 height=9> Contains new posts since last visit.<br>
			<img alt="Old Posts" src="icon_folder.gif" width=8 height=9> No new posts since the last visit.<br>
			</font>
			</td>
		</tr>
		</table>
	</td>
</tr>
</table>


<% set rs = nothing 
   set rsForum = nothing %>
<!--#INCLUDE FILE="inc_footer.asp" -->
<% sub PostingOptions() 
	if (mlev = 4) or (lcase(strNoCookies) = "1") then %>
    <font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
    <a href="post.asp?method=Category"><img border="0" src="icon_folder_new_topic.gif" alt="Create New Category" height=15 width=15 border=0></a>
    </font>
<%	end if 
   end sub 

function ChkIsNew(dt)
	if rsForum("F_STATUS") <> 0 then
		if dt > Session(strCookieURL & "last_here_date") then
			ChkIsNew =  "<IMG src='icon_folder_new.gif' height=15 width=15 border=0 hspace=0 alt='New Posts'>" 
		Else
			ChkIsNew = "<IMG src='icon_folder.gif' height=15 width=15 border=0 hspace=0 alt='Old Posts'>" 
		end if
	else
		ChkIsNew = "<IMG src='icon_folder_locked.gif' height=15 width=15 border=0 hspace=0 alt='Forum Locked'>"
	end if
end function

sub CategoryAdminOptions() 
			if (mlev = 4) or (lcase(strNoCookies) = "1") then 
				if (rs("CAT_STATUS") <> 0) then %>
          <a href="JavaScript:openWindow('pop_lock.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>&Cat_Title=<% =ChkString(rs("CAT_NAME"),"JSurlpath")%>')"><img src="icon_lock.gif" alt="Lock Category" border="0" hspace="0"></a>
<%				else %>
          <a href="JavaScript:openWindow('pop_open.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>')"><img src="icon_unlock.gif" alt="Un-Lock Category" border="0" hspace="0"></a>
<%				end if 
				if (rs("CAT_STATUS") <> 0) or (mlev = 4) then %>
          <a href="post.asp?method=EditCategory&CAT_ID=<% =rs("CAT_ID") %>&Cat_Title=<% =ChkString(rs("CAT_NAME"),"urlpath") %>"><img src="icon_pencil.gif" alt="Edit Category Name" border="0" hspace="0"></a>
<%				end if %>
          <a href="JavaScript:openWindow('pop_delete.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>&Cat_Title=<% =ChkString(rs("CAT_NAME"),"JSurlpath") %>')"><img src="icon_trashcan.gif" alt="Delete Category" border="0" hspace="0"></a>
<%				if (rs("CAT_STATUS") <> 0) or (mlev = 4) then %>
          <a href="post.asp?method=Forum&CAT_ID=<% =rs("CAT_ID")%>&type=0"><img border="0" src="icon_folder_new_topic.gif" alt="Create New Forum" border=0 hspace="0"></a>
<%				end if 
				if (rs("CAT_STATUS") <> 0) or (mlev = 4) then %>
          <a href="post.asp?method=URL&CAT_ID=<% =rs("CAT_ID")%>&type=1"><img border="0" src="icon_url.gif" alt="Create New Web Link" border=0 hspace="0"></a>
<%				end if 
			else %>
          &nbsp;
<%			end if
end sub 

sub ForumAdminOptions() 
if (mLev = 4) or (chkForumModerator(rsForum("FORUM_ID"), strDBNTUserName) = "1") or (lcase(strNoCookies) = "1") then
	if rsForum("F_TYPE") = 0 then
			if rs("CAT_STATUS") = 0 then
				if (mlev = 4) then %>
          <a href="JavaScript:openWindow('pop_open.asp?mode=Category&CAT_ID=<% =rs("CAT_ID") %>')"><img src="icon_unlock.gif" alt="Un-Lock Category" border="0" hspace="0"></a>
<%				end if
				else 
					if rsForum("F_STATUS") = 1 then %>
          <a href="JavaScript:openWindow('pop_lock.asp?mode=Forum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"JSurlpath")%>')"><img src="icon_lock.gif" alt="Lock Forum" border="0" hspace="0"></a>
<%					else %>
          <a href="JavaScript:openWindow('pop_open.asp?mode=Forum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"JSurlpath")%>')"><img src="icon_unlock.gif" alt="Un-Lock Forum" border="0" hspace="0"></a>
<%					end if 
				end if
			end if
			if rsForum("F_TYPE") = 0 then
				if (rs("CAT_STATUS") <> 0 and rsForum("F_STATUS") <> 0) or (mlev = 4 or mlev = 3) then %>
          <a href="post.asp?method=EditForum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>&type=0"><img src="icon_pencil.gif" alt="Edit Forum Properties" border="0" hspace="0"></a>
<%					end if
				else 
					if rsForum("F_TYPE") = 1 then %>
          <a href="post.asp?method=EditURL&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>&type=1"><img src="icon_pencil.gif" alt="Edit URL Properties" border="0" hspace="0"></a>
<%					end if 
				end if 
				if (mlev = 4) or (lcase(strNoCookies) = "1") then %>
          <a href="JavaScript:openWindow('pop_delete.asp?mode=Forum&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"JSurlpath") %>')"><img src="icon_trashcan.gif" alt="Delete Forum" border="0" hspace="0"></a>
<%				end if
				if rsForum("F_TYPE") = 0 then
					if (mlev = 4) or (lcase(strNoCookies) = "1") then %>
          <a href="post.asp?method=Topic&FORUM_ID=<% =rsForum("FORUM_ID") %>&CAT_ID=<% =rsForum("CAT_ID") %>&Forum_Title=<% =ChkString(rsForum("F_SUBJECT"),"urlpath") %>"><img src="icon_folder_new_topic.gif" alt="New Topic" height=15 width=15 border=0></a>
<%					end if
				end if 
	end if
end sub 

sub WriteStatistics() 

	Dim Forum_Count
	Dim NewMember_Name, NewMember_Id, Member_Count
	Dim LastPostDate, LastPostLink

	set rs = Server.CreateObject("ADODB.Recordset")
	
	Forum_Count = intForumCount

	'## Forum_SQL - Get newest membername and id from DB
	strSql = "SELECT M_NAME, MEMBER_ID FROM " & strMemberTablePrefix & "MEMBERS WHERE M_STATUS=1 AND MEMBER_ID > 1"
	strSql = strSQL & " ORDER BY M_DATE desc;"
	set rs = my_Conn.Execute(strSql)
	if not rs.EOF then
		NewMember_Name = rs("M_NAME")
		NewMember_Id = rs("MEMBER_ID")
	else 
		NewMember_Name = ""
	end if
    
      '## Forum_SQL - Get Active membercount from DB 
	strSql = "SELECT COUNT(MEMBER_ID) AS U_COUNT FROM " & strMemberTablePrefix & "MEMBERS WHERE M_POSTS > 0 AND M_STATUS=1"
	set rs = my_Conn.Execute(strSql)
	if not rs.EOF then
		Member_Count = rs("U_COUNT")
	else
		Member_Count = 0
	end if

	
	LastPostDate = ""
 	LastPostLink = ""
	LastPostAuthorLink = ""
	
	if not (intLastPostForum_ID = "") then	
	
		'## Forum_SQL - Get lastPostDate and link to that post from DB
		strSql = "SELECT " & strTablePrefix & "FORUM.CAT_ID, " & strTablePrefix & "FORUM.FORUM_ID, " 
		strSql = strSql & strTablePrefix & "FORUM.F_SUBJECT, " & strTablePrefix & "TOPICS.TOPIC_ID, " & strTablePrefix & "TOPICS.T_SUBJECT, "
		strSql = strSql & strTablePrefix & "TOPICS.T_LAST_POST, " & strMemberTablePrefix & "MEMBERS.M_NAME, " & strMemberTablePrefix & "MEMBERS.MEMBER_ID "
		strSql = strSql & "FROM " & strTablePrefix & "FORUM, " & strTablePrefix & "TOPICS, "
		strSql = strSql & strMemberTablePrefix & "MEMBERS "
		strSql = strSql & " WHERE " & strTablePrefix & "FORUM.FORUM_ID = " & strTablePrefix & "TOPICS.FORUM_ID "
		strSql = strSql & " AND " & strTablePrefix & "FORUM.CAT_ID = " & strTablePrefix & "TOPICS.CAT_ID "
		strSql = strSql & " AND " & strTablePrefix & "TOPICS.T_LAST_POST_AUTHOR = " & strMemberTablePrefix & "MEMBERS.MEMBER_ID "
		strSql = strSql & " AND " & strTablePrefix & "FORUM.FORUM_ID = " & intLastPostForum_ID & " "
		strSql = strSql & "ORDER BY " & strTablePrefix & "TOPICS.T_LAST_POST DESC;"

	 	set rs = my_Conn.Execute(strSql)
 	
 		if not rs.EOF then
			LastPostDate = ChkDate(rs("T_LAST_POST")) & ChkTime(rs("T_LAST_POST"))
			LastPostLink = "topic.asp?TOPIC_ID=" & rs("TOPIC_ID") & "&FORUM_ID=" & rs("FORUM_ID") & "&CAT_ID=" & rs("CAT_ID")
			LastPostLink = LastPostLink  & "&Topic_Title=" & ChkString(rs("T_SUBJECT"),"urlpath")
			LastPostLink = LastPostLink  & "&Forum_Title=" & ChkString(rs("F_SUBJECT"),"urlpath") 
			LastPostAuthorLink = " by: "
			strMember_ID = rs("MEMBER_ID")
			strM_NAME = rs("M_NAME")
			if strUseExtendedProfile then
				LastPostAuthorLink = LastPostAuthorLink & "<a href=""pop_profile.asp?mode=display&id="& strMember_ID & """>"
			else
				LastPostAuthorLink = LastPostAuthorLink & "<a href=""JavaScript:openWindow2('pop_profile.asp?mode=display&id=" & strMember_ID & "')"">"
			end if
            LastPostAuthorLink = LastPostAuthorLink  & strM_NAME & "</a>"
		end if
	end if

	ActiveTopicCount = -1
	if not IsNull(Session(strCookieURL & "last_here_date")) then 
		if not blnHiddenForums then
			'## Forum_SQL - Get ActiveTopicCount from DB
			strSql = "SELECT COUNT(" & strTablePrefix & "TOPICS.T_LAST_POST) AS NUM_ACTIVE "
			strSql = strSql & "FROM " & strTablePrefix & "TOPICS "
			strSql = strSql & "WHERE (((" & strTablePrefix & "TOPICS.T_LAST_POST)>'"& Session(strCookieURL & "last_here_date") & "'))"

			set rs = my_Conn.Execute(strSql)
			if not rs.EOF then
				ActiveTopicCount = rs("NUM_ACTIVE")
			else
				ActiveTopicCount = 0
			end if
		end if
	end if

	rs.close
	set rs = nothing
	ShowLastHere = (cint(ChkUser2(strDBNTUserName, Request.Cookies(strCookieURL & "User")("Pword"))) > 0)
%>
		<tr>
          <td bgcolor="<% =strCategoryCellColor %>" colspan="<% if (strShowModerators = "1") or (mlev = 4 or mlev = 3) then Response.Write("7") else Response.Write("5")%>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>" color="<% =strCategoryFontColor %>" size="+1"><b>Statistics</b></font></td>
        </tr>
        <tr>
          <td rowspan="<% if ShowLastHere then Response.Write("5") else Response.Write("4") end if %>" bgcolor="<%= strForumCellColor %>">&nbsp;</td>
          <% if ShowLastHere then %>
           <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>">
		    <font align=left face="<% =strDefaultFontFace %>" size="<% =strFooterFontSize %>">You last visited on <% =ChkDate(Session(strCookieURL & "last_here_date")) %> <% =ChkTime(Session(strCookieURL & "last_here_date")) %></font>
		  </td>
	    </tr>
	    <tr>
		  <% end if %>
		<% if intPostCount > 0 then %>
          <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>">
          <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>"><% if Member_Count = 1 then Response.Write("1 Member has ") else Response.Write(Member_Count & " Members have ") end if%> 
		  made <% if intPostCount = 1 then Response.Write("1 post ") else Response.Write(intPostCount & " posts") end if%>
		  in <% if intForumCount = 1 then Response.Write("1 forum") else Response.Write(intForumCount & " forums") end if%>
		  <%if (LastPostDate = "" or LastPostLink = "" or intPostCount = 0) then 
			Response.Write("") 
		    else
			Response.Write(", with the last post on <a href=""" & lastPostLink & """>"& lastPostDate & "</a>")
			if  LastPostAuthorLink <> "" then
				Response.Write(LastPostAuthorLink & ".")
			else
				Response.Write(".")
			end if
		    end if%>
		  </font>
          </td>
        </tr>
        <tr>
        <% end if %>      
          <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>">
            <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">There <%if intTopicCount = 1 then Response.Write("is ") else Response.Write("are ") end if%> currently <%= intTopicCount %> <%if intTopicCount = 1 then Response.Write(" topic") else Response.Write(" topics") end if %> 
            <% if ActiveTopicCount > 0 then %>
            and <%= ActiveTopicCount %> <a href="active.asp">active <%if ActiveTopicCount = 1 then Response.Write("topic") else Response.Write("topics") end if%></a> since you last visited.         
            <% elseif blnHiddenForums and (strLastPostDate > Session(strCookieURL & "last_here_date")) and ShowLastHere then %>
		and there are <a href="active.asp">active topics</a> since you last visited.         
		<% elseif not(ShowLastHere) then Response.Write(".")
		   else%>
            and no active topics since you last visited.
            <% end if %>
            </font>
          </td>
        </tr>
        <% if NewMember_Name <> "" then %>
        <tr>          
          <td bgcolor="<%= strForumCellColor %>" colspan="<% if ((strShowModerators = "1") or (mlev = "4" or mlev = "3")) then Response.Write("6") else Response.Write("4") end if%>">
            <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>">Please welcome our newest member:
<%          if strUseExtendedProfile then
				Response.Write("<a href=""pop_profile.asp?mode=display&id="& NewMember_Id & """>")
			else
				Response.Write("<a href=""JavaScript:openWindow2('pop_profile.asp?mode=display&id=" & NewMember_Id & "')"">")
			end if
			Response.Write(NewMember_Name & "</a>.</font>")
%>
          </td>
        </tr>
        <% end if 
end sub %>
