<% Option Explicit %>
<!--#include file="config.asp"-->
<!--#include file="common.asp"-->
<%
	Command	= Request.Form("Command")

	OpenConnection


	If Session("IsAdminLogin") Then
		If Command = "Save" Then
			SiteName		= Request.Form("SiteName")
			MyEGold			= Str2Num(Request.Form("MyEGold"))
			Password		= Request.Form("Password")
			ContactEMail	= Request.Form("ContactEMail")
			SponsorEarn		= Str2Num(Request.Form("SponsorEarn"))
			EGoldPass		= Request.Form("EGoldPass")
			AltPass			= Request.Form("AltPass")
			LuckyNumber		= Request.Form("LuckyNumber")
			Bet				= Request.Form("Bet")
			Win				= Request.Form("Win")
			MaxLinks		= Request.Form("MaxLinks")
			LinkCost		= Request.Form("LinkCost")

			DBC.Execute("UPDATE Admin SET " & _
				"SiteName		= " & EscapeSQLData(SiteName)		& "," & _
				"MyEGold		= " & MyEGold						& "," & _
				"Password		= " & EscapeSQLData(Password)		& "," & _
				"ContactEMail	= " & EscapeSQLData(ContactEMail)	& "," & _
				"SponsorEarn	= " & SponsorEarn					& "," & _
				"EGoldPass		= " & EscapeSQLData(EGoldPass)		& "," & _
				"AltPass		= " & EscapeSQLData(AltPass)		& "," & _
				"LuckyNumber	= " & EscapeSQLData(LuckyNumber)	& "," & _
				"Bet			= " & EscapeSQLData(Bet)			& "," & _
				"Win			= " & EscapeSQLData(Win)			& "," & _
				"MaxLinks		= " & EscapeSQLData(MaxLinks)		& "," & _
				"LinkCost		= " & EscapeSQLData(LinkCost)		& " " & _
				"WHERE ID = 1")
		End If

		PageHeader
		AdminMenu
	Else
		PageHeader
		UserLogin
		Response.End
	End If


	Edit
%>
	</body>
	</html>
<%

	Sub Edit()
		Dim rs
		Set rs = DBC.Execute("SELECT Password FROM Admin")

		If rs.EOF Then
			Password = ""
		Else
			Password = rs("Password")
		End If
%>
		<script language=JavaScript>
		<!--
		function Validate()
		{
			if (document.EF.SiteName.value.length == 0)
			{
				alert("Please enter Your site`s title.");
				document.EF.SiteName.focus();
				return false;
			}

			if (document.EF.MyEGold.value.length == 0)
			{
				alert("Please enter Your e-gold number.");
				document.EF.MyEGold.focus();
				return false;
			}
			else
			{
				if (isNaN(document.EF.MyEGold.value))
				{
					alert("Please enter Your e-gold number.");
					document.EF.MyEGold.focus();
					return false;
				}
			}

			if (document.EF.EGoldPass.value.length == 0)
			{
				alert("Please enter Your e-gold passphrase.");
				document.EF.EGoldPass.focus();
				return false;
			}

			if (document.EF.AltPass.value.length == 0)
			{
				alert("Please enter Your alternate e-gold passphrase.");
				document.EF.AltPass.focus();
				return false;
			}

			if (document.EF.Password.value.length == 0)
			{
				alert("Please enter a password.");
				document.EF.Password.focus();
				return false;
			}

			if (document.EF.SponsorEarn.value.length == 0)
			{
				alert("Please enter a commission for direct referrals (%).");
				document.EF.SponsorEarn.focus();
				return false;
			}
			else
			{
				if (isNaN(document.EF.SponsorEarn.value))
				{
					alert("Please enter a commission for direct referrals (%).");
					document.EF.SponsorEarn.focus();
					return false;
				}
			}

			if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.EF.ContactEMail.value))
			{ }
			else
			{
				alert("Please enter Your e-mail address.");
				document.EF.ContactEMail.focus();
				return false;
			}

			if (document.EF.LuckyNumber.value.length == 0)
			{
				alert("Please enter the Lucky Number.");
				document.EF.LuckyNumber.focus();
				return false;
			}
			else
			{
				if (isNaN(document.EF.LuckyNumber.value))
				{
					alert("Please enter the Lucky Number.");
					document.EF.LuckyNumber.focus();
					return false;
				}
			}

			if (document.EF.Bet.value.length == 0)
			{
				alert("Please enter a bet.");
				document.EF.Bet.focus();
				return false;
			}
			else
			{
				if (isNaN(document.EF.Bet.value))
				{
					alert("Please enter a bet.");
					document.EF.Bet.focus();
					return false;
				}
			}

			if (document.EF.Win.value.length == 0)
			{
				alert("Please enter a player winnings.");
				document.EF.MyEGold.focus();
				return false;
			}
			else
			{
				if (isNaN(document.EF.Win.value))
				{
					alert("Please enter a player winnings.");
					document.EF.Win.focus();
					return false;
				}
			}

			if (document.EF.MaxLinks.value.length == 0)
			{
				alert("Please enter a number.");
				document.EF.MyEGold.focus();
				return false;
			}
			else
			{
				if (isNaN(document.EF.MaxLinks.value))
				{
					alert("Please enter a number.");
					document.EF.MaxLinks.focus();
					return false;
				}
			}

			if (document.EF.LinkCost.value.length == 0)
			{
				alert("Please enter a link cost.");
				document.EF.LinkCost.focus();
				return false;
			}
			else
			{
				if (isNaN(document.EF.LinkCost.value))
				{
					alert("Please enter a link cost.");
					document.EF.LinkCost.focus();
					return false;
				}
			}

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

		<form name=EF action="admin_main.asp" method=post onsubmit="return Validate()">
		<table border=0 align=center class=Header cellspacing=1 cellpadding=3>
		<tr>
			<td colspan=2 align=center>
				Main
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Site's title</td>
			<td>
				<input name=SiteName value="<%= SiteName %>" size=25 maxlength=40 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Your e-gold number</td>
			<td>
				<input name=MyEGold value="<%= MyEGold %>" size=25 maxlength=10 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Your e-gold passphrase</td>
			<td>
				<input name=EGoldPass value="<%= EGoldPass %>" size=25 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Your alternate e-gold passphrase</td>
			<td>
				<input name=AltPass value="<%= AltPass %>" size=25 maxlength=50 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Choose password for the Administration Area</td>
			<td>
				<input name=Password value="<%= Password %>" size=25 maxlength=50 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Commission for direct referrals ($)</td>
			<td>
				<input name=SponsorEarn value="<%= SponsorEarn %>" size=25 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Your e-mail (contact e-mail)</td>
			<td>
				<input name=ContactEMail value="<%= ContactEMail %>" size=25 maxlength=50 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Choose the Lucky Number</td>
			<td>
				<input name=LuckyNumber value="<%= LuckyNumber %>" size=25 maxlength=1 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Bet ($)</td>
			<td>
				<input name=Bet value="<%= Bet %>" size=25 maxlength=10 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Win ($)</td>
			<td>
				<input name=Win value="<%= Win %>" size=25 maxlength=10 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Max links</td>
			<td>
				<input name=MaxLinks value="<%= MaxLinks %>" size=25 maxlength=10 class=ClientText>
			</td>
		</tr>
		<tr class=PageText bgcolor=white>
			<td>Link cost for a month ($)</td>
			<td>
				<input name=LinkCost value="<%= LinkCost %>" size=25 maxlength=10 class=ClientText>
			</td>
		</tr>
		<tr>
			<td colspan=2 bgcolor=white align=center>
				<input type=hidden name=Command value=Save>
				<input type=submit value=Save>
			</td>
		</tr>
		</table>
		</form>
		<br>
<%
	End Sub
%>