<%
	Response.Expires = 0
	Response.CacheControl = "no-cache"
	response.Buffer = true
	
	i_CatID  = request("CatID")
	if i_CatID =  empty then 
		response.Redirect("lib_cat.asp?cache="&now())
	end if
	Set con = Server.CreateObject("ADODB.Connection")
	con.Open Application("CString")
	s_Heading= "File &amp; Document Library"
%>
<html>
<head>
<title><% = request("CatName")%> :. P.K. Ferraris & Associates - Financial Planning South Africa</title>
<!--#include file="meta.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="javaFunctions.js"></script>
</head>

<body>
<!--#include file="header.asp"-->
<h1><% = request("CatName")%></h1>
 <%
		  strSQL = "SELECT * FROM CMS_Page WHERE CategoryID = "& i_CatID &" Order by Heading"
			set rsFiles = server.createobject("ADODB.Recordset")
			rsFiles.open strSQL, con, 3, 1
			  
			if rsFiles.EOF then %>
            <p>We are in the process of updating our database.</p>
			  <%
			  else 
			  	%>
				<%
					rsFiles.PageSize = 10
						
					intPageCount = rsFiles.PageCount
					
					if request("intPage") <> empty and IsNumeric(request("intPage")) then
						intPage = CInt(request("intPage"))
					else
						intPage = 1
					end if
					
					if intPage > intPageCount then
						intPage = intPageCount
					elseif intPage < 1 then
						intPage = 1
					end if
					
					rsFiles.AbsolutePage = intPage			  
			  %>
			  
			 
			  
			  <ul><%	for i = 1 to rsFiles.PageSize
								  
							i_PageID 		= rsFiles("PageID")
							i_CategoryID 	= rsFiles("CategoryID")
							s_Heading 		= rsFiles("Heading")
							s_FileName 		= rsFiles("FileName")
							s_FileSize 		= rsFiles("FileSize")

			  %>
                    <li><a href="Uploads/<% = s_FileName%>" target="_blank" ><b><% = s_Heading %></b></a> [<%=Server.HTMLEncode(s_FileName)%>] <%=Round(s_FileSize/1024)%>Kb</li>
                <%
			  			
			  
			  		rsFiles.MoveNext()
                    if rsFiles.EOF then exit for
                    Next
								
			  end if
			  
			  set rsFiles = Nothing
			  %>
			</ul>
<%  	if intPagecount > 1 then %>
<table border="0" cellspacing="0" cellpadding="0">
				<tr align="center">
				   <td width="80"><p>More&nbsp;records:</p></td>
						 <%
							for i=1 to intPagecount
									if i = CDbl(intPage) then
								%>
									<td width="17" height="22" background="images/page_on.gif"><p><%=i%></p> </td> 
								<% else%>
									<td width="17" height="22" background="images/page_off.gif" style="cursor:hand;" onClick="javascript:window.open('lib_cat.asp?intPage=<%=i%>&Cat=<%=request("Cat")%>','_self');"><p><%=i%></p></td> 
								<% end if
							next
						%>
				</tr>
			</table><%end if%>
			 <br>
          <input name="Button" type="button" class="button" value="Back To Index" onClick="javascript:window.open('lib_cat.asp?cache=<%=now()%>','_self','');">
         
	  
        <!--#include file="footer.asp"-->
</body>
</html>
