<% Option Explicit %>
<!--#include file="config.asp"-->
<!--#include file="common.asp"-->
<%
	PageHeader

	If Session("IsAdminLogin") Then
		AdminMenu
	Else
		UserLogin
		Response.End
	End If


	Command	= Request.Querystring("Command")

	OpenConnection

	If Command = "Delete" Then
		DBC.Execute("DELETE FROM Links WHERE LinkID = " & Str2Num(Request.Querystring("LinkID")))
	End If

	LinksList


	Sub LinksList()
		Dim rs, i

		Set rs = DBC.Execute("SELECT * FROM Links ORDER BY LinkID DESC")
%>
		<p align=center>
		<a href="admin_links_edit.asp">Add Link</a><br><br>
		</p>

		<form>
		<table border=0 align=center bgcolor=FFEFB2 width=600 cellspacing=1 cellpadding=3>
		<col>
		<col>
		<col align=center>
		<col align=right>
		<col align=right>
		<col align=center>
		<tr class=PageText>
			<td align=center>N</td>
			<td align=center><font color=black>Link</font></td>
			<td align=center><font color=black>Advertiser's e-gold</font></td>
			<td align=center><font color=black>Batch number</font></td>
			<td align=center><font color=black>Active to date</font></td>
			<td>&nbsp;</td>
		</tr>
<%
		i = 1
		Do While Not rs.EOF
%>
			<tr bgcolor=white class=PageText>
				<td><%= i %>.</td>
				<td><a href="<%= rs("URL") %>" target=_blank><%= rs("Title") %></a></td>
				<td><%= rs("FromEGold") %></td>
				<td><%= rs("BatchNumber") %></td>
				<td><%= rs("ValidTo") %></td>
				<td>
					<a href="admin_links_edit.asp?LinkID=<%= rs("LinkID") %>">Modify</a>&nbsp;
					<a href="javascript: Delete(<%= rs("LinkID") %>)">Delete</a>
				</td>
			</tr>
<%
			i = i + 1
			rs.MoveNext
		Loop
%>
		</table>
		</form>
		<br>

		<script language=JavaScript>
		<!--
		function Delete(ID)
		{
			if (confirm("This record will be delete. Do you want to proceed."))
				document.location = "admin_links.asp?Command=Delete&LinkID=" + ID;
		}
		//-->
		</script>
<%
	End Sub
%>