<!-- #INCLUDE VIRTUAL="/_includes/functions.asp"-->
<!-- #INCLUDE VIRTUAL="/_includes/isadmin.asp"-->
<%
'-----------------------------------------------------------------
'--Page info
'-----------------------------------------------------------------
PAGE_NAME = "Program"
PAGE_NAME_S = "Programs"

Set DB = New clsDatabase
	DB.OpenDatabase DATABASE_NAME , DATABASE_USERNAME , DATABASE_PASSWORD

	strQuery = "SELECT library_categories.id, library_categories.name, library_programs.id, library_programs.name, library_programs.large_image FROM library_categories, library_programs WHERE library_categories.id = library_programs.category_id ORDER BY library_categories.id, library_categories.name, library_programs.id, library_programs.name"

	'------------------------------------
	'--select records
	'------------------------------------
	numOfRecords = DB.RunQuery(strQuery) - 1


	If numOfRecords > -1 Then retRecords = DB.GetLastResults()

Set DB = Nothing
%>
<HTML>
<HEAD>
		<script language="javascript">
			function delete_item(id){
				if(confirm('Are you sure you want to delete this item?\nALL ASSOCIATED RECORDS WILL BE DELETED!')){
					document.location='delete.asp?ID='+id;
				}
			}
		</script>
		<link href="/_cms/style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<CENTER><TABLE WIDTH="100%" border="0">
	<TR>
		<TD colspan="4" align="center"><BR><font class="txtPageHdr">Managing <%=PAGE_NAME_S%></font><font class="txtReg"><BR><BR></font></td>
	</TR>
</TABLE>
<%
If numOfRecords < 0 Then
	Response.Write "<table width=""90%"" border=""0"" cellspacing=""0"" cellpadding=""0"">" & _
	"<tr>" & _
	"	<td width=""100%"" align=""center""><FONT class=""txtReg""><BR>None at the moment!</font></td>" & _
	"</table>"

	orderButtonState = " disabled"
Else
	If numOfRecords < 1 Then orderButtonState = " disabled"

	strLastCategory = ""

	For x=0 To numOfRecords

		Response.Write "<table width=""90%"" border=""0"" cellspacing=""0"" cellpadding=""0"">"

		If strLastCategory <> retRecords(0,x) Then
			strLastCategory = retRecords(0,x)
			
			Response.Write "<tr><td width=""100%""colspan=""3""><FONT class=""txtBig""><br><B>" &  retRecords(1,x) & "</b></font></td></tr>"
			Response.Write "<tr><td height=""2"" width=""100%"" bgcolor=""#666666"" colspan=""3""><img src=""../images/spacer.gif"" width=""1"" height=""1"" align=""absmiddle""></td></tr>"

		End If

		If x MOD 2 = 0 Then
			trClass = "NormalRow"
		Else
			trClass = "AlternatRow"
		End If

		Response.Write "<tr class=""" & trClass & """ onMouseOver=""this.className='MouseOverRow';"" onMouseOut=""this.className='" & trClass & "';"">" & _
		"<td width=""2%""><img src="""&PROGRAM_IMAGE_PATH & retRecords(4,x)&""" border=""0"" width=""40"" height=""40"" vspace=""2"" /></td>" & _
		"<td width=""73%""><FONT class=""txtReg""><B>&nbsp;" & retRecords(3,x) & "</b></font></td>" & _
		"<td width=""25%"" align=""right"" ><FONT class=""txtReg"">" & _
		"<a class=lnkNormal href=""edit.asp?ID=" & retRecords(2,x) & """><img src=""/_cms/images/icons/edit.gif"" width=""12"" height=""12"" border=""0"" hspace=""1"" vspace=""0"" align=""absmiddle"">Edit Info</a>&nbsp;|&nbsp;" & _
		"<a class=lnkNormal href="""" onClick=""delete_item(" & retRecords(2,x) & ");return false;""><img src=""/_cms/images/icons/delete.gif"" width=""12"" height=""12"" border=""0"" hspace=""1"" vspace=""0"" align=""absmiddle"">Delete</a>&nbsp;" & _
		"</font></td></tr>"

	Next
	Response.write "</table>"
End If
%>
<FORM ACTION="index.asp" method="POST">
<TABLE WIDTH="100%" align="center" border="0">
	<TR>
		<TD colspan="2" align="center"><BR><!-- <INPUT TYPE="button" NAME="action" VALUE="<%=PAGE_NAME_S%> Ordering" <%=orderButtonState%> onClick="document.location='order.asp';">&nbsp;&nbsp;&nbsp; --><INPUT TYPE="button" NAME="action" VALUE="Add <%=PAGE_NAME_S%>" onClick="document.location='add.asp';"><br><br></TD>
	</TR>
</TABLE>
</FORM>
</CENTER>
</body>
</HTML>