<%
'#############
'# The below sets the pagesize (number of entries per page)
'#############
strGuestbookPageSize = 2
'#############
'# Do not edit below this line
'#############
strTempFont = "<font face=""" & strDefaultFontFace & """ size=" & strFooterFontSize & ">"
strsql = "SELECT G_ID, G_VARFIELD1, G_VARFIELD2, G_VARFIELD3, G_V1_SWITCH, G_V2_SWITCH, G_V3_SWITCH, G_MESSAGE FROM " & strTablePrefix & "GB_OPTIONS WHERE G_ID=1"
set optionrs = my_conn.execute(strsql)
if not optionrs.eof then
	strV1 = optionrs("G_VARFIELD1")
    strV2 = optionrs("G_VARFIELD2")
    strV3 = optionrs("G_VARFIELD3")
    
    strV1E = optionrs("G_V1_SWITCH")
    strV2E = optionrs("G_V2_SWITCH")
    strV3E = optionrs("G_V3_SWITCH")
    
    strGuestbookWelcome = optionrs("G_MESSAGE")
set optionrs = nothing
end if
set countrs = my_conn.execute("SELECT G_ID FROM " & strTablePrefix & "GUESTBOOK")
	rec = 0
    do until countrs.eof
    	rec = rec + 1
    countrs.movenext
    Loop
set countrs = nothing

strTotalRecords = rec


strGAction = "view"


%>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<table border=0 cellspacing=0 cellpadding=1 width="100%">
<tr><td>
<table width=100% cellspacing=1 cellpadding=1 bgcolor="<%=strTableBorderColor%>">
  <tr bgcolor="<%=strHeadCellColor%>">
    <td align="center" >
      <strong><font face="<%=strDefaultFontFace%>" size=<%=strDefaultFontSize%> color="<%=strHeadFontColor%>">
        Guestbook
      </strong></font>
    </td>
  </tr>
  <tr bgcolor="<%=strForumCellColor%>">
    <td align="left">
      <font face="<%=strDefaultFontFace%>" size="<%=strDefaultFontSize%>" color="<%=strForumFontColor%>">
        There are <%=strTotalRecords%> signatures
      </font>
    </td>
  </tr>
<% 
Select Case strGAction
	Case "view"
    	strSortMethod = request.querystring("sortby")
    	if strSortMethod = "" then
        strSortMethod = "DESC"
        end if
        
    	intPage = request.querystring("page")
    	strsql = "SELECT G_ID, G_NAME, G_EMAIL, G_WEBSITE, G_ICQ, G_DATE, G_VARFIELD1, G_VARFIELD2, G_VARFIELD3, G_MESSAGE FROM " & strTablePrefix & "GUESTBOOK ORDER BY G_ID " & strSortMethod
        Set grs = Server.CreateObject("ADODB.Recordset")
        grs.Open strsql, my_Conn ,3
		' Set the PageSize, CacheSize, and populate the intPageCount and 
		' intRecordCount variables.
		grs.PageSize = strGuestbookPageSize	
		' The cachesize property sets the number of records that will be cached 
		' locally in memory.

        strGTotalPages = grs.PageCount
			If request.querystring("page") = "" then
            	ipage = 1
            else
            	ipage = Cint(request.querystring("page"))
            End if 
        	if grs.eof then %>
            	
  <tr bgcolor="<%=strForumCellColor%>">
    <td align="left">
      <font face="<%=strDefaultFontFace%>" size="<%=strDefaultFontSize%>" color="<%=strForumFontColor%>">
        No one has signed the guestbook yet
      </font>
    </td>
  </tr>

<%            else
            	%><tr bgcolor="<%=strForumCellColor%>"><td >
                <table align="center"  cellpadding="3" cellspacing="1" width=100%>
                <%
                if strGTotalPages > "1" then
                	Call subgpaging()
                End if                
                rec = 0
                grs.absolutepage = ipage
            	do until rec = grs.PageSize or grs.eof
                strTempID      = ChkString(grs("G_ID"), "display")
                strTempName    = ChkString(grs("G_NAME"), "display")
                strTempEmail   = ChkString(grs("G_EMAIL"), "display")
                strTempWebsite = ChkString(grs("G_WEBSITE"), "display")
                strTempICQ     = ChkString(grs("G_ICQ"), "display")
                strTempMessage = formatStr(grs("G_MESSAGE"))
                strTempDate    = strToDate(grs("G_DATE"))
                	if grs("G_VARFIELD1") <> "" and strV1E = 1 then
                strTempField1  = ChkString(grs("G_VARFIELD1"), "display")
                	End if
                    if grs("G_VARFIELD2") <> "" and strV2E = 1 then
                strTempField2  = ChkString(grs("G_VARFIELD2"), "display")
                	End if
                    if grs("G_VARFIELD3") <> "" and strV3E = 1 then
                strTempField3  = ChkString(grs("G_VARFIELD3"), "display")
                	End if
                %>
                <tr>
                	<td bgcolor="<%=strCategoryCellColor%>">
                    	<font size="<%=strFooterFontSize%>" color="<%=strHeadFontColor%>" face="<%=strDefaultFontFace%>"><b>Posted By:</b></font> 		
						<font face="<%=strDefaultFontFace%>" size=<%=strFooterFontSize%> color="<%=strHeadFontColor%>"><a href="mailto:<%=strTempEmail%>" title="Send Email to <%=strTempName%> at <%=strTempEmail%>"><font color="<%=strHeadFontColor%>"><%=strTempName%></font></a></font>&nbsp;
                        <font size="<%=strFooterFontSize%>" color="<%=strHeadFontColor%>" face="<%=strDefaultFontFace%>">Date:</font> 
						<font face="<%=strDefaultFontFace%>" size=<%=strFooterFontSize%> color="<%=strHeadFontColor%>"><%=displayDate(datetostr(strTempDate))%></font>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="<%=strForumCellColor%>">
                    	<table border=0 align="left" >
                        	<tr><td align="left">
							<%=strTempFont & strTempMessage%></font></td></tr>
                        </table>
                    </td>
                </tr>
                <%
                rec = rec + 1
                grs.movenext
                Loop
                %>
                </table>
				</td></tr>
  <tr bgcolor="<%=strForumCellColor%>">
    <td align="center">
      <font face="<%=strDefaultFontFace%>" size="<%=strDefaultFontSize%>">
        <a href="<%= strForumURL %>guestbook.asp?action=sign">Sign it!</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<%= strForumURL %>guestbook.asp?action=view">View it!</a>
      </font>
    </td>
  </tr>
<% 	mLev = cint(chkUser(strDBNTUserName, Request.Cookies(strUniqueID & "User")("Pword")))
if ((mlev = 4) or (mlev = 3)) then %>
  <tr bgcolor="<%=strForumCellColor%>">
    <td align="center" >
      <font face="<%=strDefaultFontFace%>" size="<%=strDefaultFontSize%>">
        <a href="<%= strForumURL %>admin_guestbook.asp?action=options">Options/Settings</a>
      </font>
    </td>
  </tr>
<% end if 
End if%>

				</table>
								</td>
				</tr>
	</table>

                <%
            
        set grs = nothing
End Select

Sub subgpaging()
		p_rec = 1
        response.write("<tr><td bgcolor=""" & strHeadCellColor & """>" & strTempFont & "Pages: " & vbcrlf)
	Do until p_rec = strGTotalPages + 1
    	response.write("<a href=""portal_content.asp?sectionid=6&action=view&page=" & p_rec & """ title=""Page " & p_rec & """>" & p_rec & "</a> | ")
    p_rec = p_rec + 1
    Loop
    	response.write("</font></td></tr>" & vbcrlf)
End Sub
%>
<br>

