<%
	Dim Command, rsUser

	Command = Request.Querystring("Command")

	If Command = "LogIn" Then
		LogIn
	End If

	If Command = "LogOut" Then
		Session("IsAdminLogin") = False
		Response.Redirect "default.asp"
	End If



	Sub LogIn()
		OpenConnection

		Set rsUser = DBC.Execute("SELECT ID FROM Admin WHERE ID = 1 AND " & _
			"MyEGold = " & Str2Num(Request.Form("EGold")) & " AND " & _
			"Password = " & EscapeSQLData(Request.Form("Password")))

		Session("IsAdminLogin") = (Not rsUser.EOF)
	End Sub


	Sub PageLogin()
%>
		<form name=LF action="adm_payments.asp?Command=LogIn" method=post onsubmit="return ValidateForm()">
		<table border=0 width=100% cellpadding=1>
		<tr>
			<td align=center class=PageText>
				E-Gold:&nbsp;
				<input name=EGold size=15 maxlength=20 class=ClientText>
				&nbsp;&nbsp;
				Password:&nbsp;
				<input type=Password name=Password size=15 maxlength=20 class=ClientText>
				&nbsp;&nbsp;
				<input type=submit value="Log In" class=Button>
			</td>
		</tr>
		</table>
		</form>

		<script language=JavaScript>
		<!--
		function ValidateForm()
		{
			if (document.LF.EGold.value.length == 0)
			{
				alert ('Please enter your E-Gold number.');
				document.LF.EGold.focus();
				return false;
			}

			if (document.LF.Password.value.length == 0)
			{
				alert ('Please enter your password.');
				document.LF.Password.focus();
				return false;
			}

			return true;
		}
		//-->
		</script>

		<script language=JavaScript for=window event=onload>
		<!--
			document.LF.EGold.focus();
		//-->
		</script>
<%
	End Sub


	Sub PageMenu()
%>
	<table border=0 width=100% cellspacing=0 cellpadding=2 bgcolor=006699>
	<tr bgcolor=white class=PageText>
		<td width=200>
			<b><%= SiteName %></b>
		</td>
		<td align=center>
			<a href=adm_main.asp>Common Info</a>&nbsp;|&nbsp;
			<a href=adm_spends.asp>Manage Spends</a>&nbsp;|&nbsp;
			<a href=adm_payments.asp>Send Money</a>&nbsp;|&nbsp;
			<a href=adm_stat.asp>Statistics</a>&nbsp;|&nbsp;
			<a href=adm_admin.asp?Command=LogOut>Log Out</a>
		</td>
		<td width=200>
			&nbsp;
		</td>
	</tr>
	</table>
<%
	End Sub
%>