<% Option Explicit %>
<!--#include file="../config.asp"-->
<!--#include file="../common.asp"-->
<!--#include file="main.asp"-->
<%
	Dim rs, Password


	PageHeader

	If Not Session("IsAdminLogin") Then
		PageLogin
		Response.End
	End If


	Command = Request.Form("Command")


	OpenConnection

	If Command = "Save" Then
		MyEGold					= Str2Num(Request.Form("MyEGold"))
		Password					= Request.Form("Password")
		ContactEMail				= Request.Form("ContactEMail")
		AltPass					= Request.Form("AltPass")
		SiteName					= Request.Form("SiteName")
		MinimumPayout				= Str2Float(Request.Form("MinimumPayout"))
		MemberDelay				= Str2Num(Request.Form("MemberDelay"))
		GoldMembershipCommission4FreeMembers	= Str2Float(Request.Form("GoldMembershipCommission4FreeMembers"))
		GoldMembershipCommission4GoldMembers	= Str2Float(Request.Form("GoldMembershipCommission4GoldMembers"))
		AdvCommission				= Str2Float(Request.Form("AdvCommission"))
		PageCost4FreeMembers			= Str2Float(Request.Form("PageCost4FreeMembers"))
		PageCost4GoldMembers			= Str2Float(Request.Form("PageCost4GoldMembers"))
		ReferralCommission				= Str2Float(Request.Form("ReferralCommission"))
		MyCommission				= Str2Float(Request.Form("MyCommission"))
		BannerCost4aMonth				= Str2Float(Request.Form("BannerCost4aMonth"))
		VisitorPackages				= Request.Form("VisitorPackages")
		MessageOnTop				= Request.Form("MessageOnTop")
		GoldFee					= Str2Float(Request.Form("GoldFee"))
		GoldMinimumPayout			= Str2Float(Request.Form("GoldMinimumPayout"))
		GoldFreeVisitors				= Str2Num(Request.Form("GoldFreeVisitors"))
		GoldBannerDays				= Str2Num(Request.Form("GoldBannerDays"))

		MsgBoldCost				= Str2Float(Request.Form("MsgBoldCost"))
		MsgHighlightCost				= Str2Float(Request.Form("MsgHighlightCost"))

		MsgCostNonMembers			= Str2Float(Request.Form("MsgCostNonMembers"))
		MsgCostFreeMembers			= Str2Float(Request.Form("MsgCostFreeMembers"))
		MsgCostGoldMembers			= Str2Float(Request.Form("MsgCostGoldMembers"))


		If Left(VisitorPackages, 1) <> " " Then
			VisitorPackages = " " & VisitorPackages
		End If

		If Right(VisitorPackages, 1) <> " " Then
			VisitorPackages = VisitorPackages & " "
		End If


		DBC.Execute("UPDATE Admin SET " & _
			"SiteName				= " & EscapeSQLData(SiteName)					& "," & _
			"MinimumPayout				= " & MinimumPayout								& "," & _
			"MemberDelay				= " & MemberDelay								& "," & _
			"EGold					= " & MyEGold									& "," & _
			"Password				= " & EscapeSQLData(Password)					& "," & _
			"ContactEMail				= " & EscapeSQLData(ContactEMail)				& "," & _
			"GoldMembershipCommission4FreeMembers	= " & EscapeSQLData(GoldMembershipCommission4FreeMembers)	& "," & _
			"GoldMembershipCommission4GoldMembers	= " & EscapeSQLData(GoldMembershipCommission4GoldMembers)	& "," & _
			"AdvCommission				= " & AdvCommission								& "," & _
			"PageCost4FreeMembers			= " & PageCost4FreeMembers							& "," & _
			"PageCost4GoldMembers			= " & PageCost4GoldMembers							& "," & _
			"ReferralCommission			= " & ReferralCommission						& "," & _
			"MyCommission				= " & MyCommission								& "," & _
			"BannerCost4aMonth			= " & BannerCost4aMonth							& "," & _
			"MessageOnTop				= " & EscapeSQLData(MessageOnTop)						& "," & _
			"VisitorPackages				= " & EscapeSQLData(VisitorPackages)			& "," & _
			"AltPass					= " & EscapeSQLData(AltPass)					& "," & _
			"GoldFee					= " & GoldFee									& "," & _
			"GoldMinimumPayout			= " & GoldMinimumPayout							& "," & _
			"GoldFreeVisitors				= " & GoldFreeVisitors							& "," & _
			"GoldBannerDays				= " & GoldBannerDays							& "," & _
			"MsgBoldCost				= " & MsgBoldCost								& "," & _
			"MsgHighlightCost				= " & MsgHighlightCost							& "," & _
			"MsgCostNonMembers			= " & MsgCostNonMembers							& "," & _
			"MsgCostFreeMembers			= " & MsgCostFreeMembers						& "," & _
			"MsgCostGoldMembers			= " & MsgCostGoldMembers)


		Application.Lock
		Application(Prefix & "MyEGold") = 0
		Application.Unlock
	End If

	AdminPageBegin "Common Info"
	Edit
	AdminPageEnd


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

		If rs.EOF Then
			SiteName					= ""
			MyEGold					= 0
			Password					= ""
			ContactEMail				= ""
			AltPass					= ""
			MinimumPayout				= 0.01
			MemberDelay				= 30
			GoldMembershipCommission4FreeMembers	= 0.5
			GoldMembershipCommission4GoldMembers	= 1
			AdvCommission				= 10
			PageCost4FreeMembers			= 0.002
			PageCost4GoldMembers			= 0.003
			ReferralCommission				= 0.001
			MyCommission				= 0.001
			BannerCost4aMonth				= 1
			VisitorPackages				= " 1000 2000 "
			MessageOnTop				= ""
			GoldFee					= 1.00
			GoldMinimumPayout			= 0.01
			GoldFreeVisitors				= 1
			GoldBannerDays				= 1

			MsgBoldCost				= 0.05
			MsgHighlightCost				= 0.05

			MsgCostNonMembers			= 0.15
			MsgCostFreeMembers			= 0.10
			MsgCostGoldMembers			= 0.05
		Else
			SiteName					= rs("SiteName")
			MyEGold					= rs("EGold")
			Password					= rs("Password")
			ContactEMail				= rs("ContactEMail")
			AltPass					= rs("AltPass")
			MinimumPayout				= rs("MinimumPayout")
			MemberDelay				= rs("MemberDelay")
			GoldMembershipCommission4FreeMembers	= rs("GoldMembershipCommission4FreeMembers")
			GoldMembershipCommission4GoldMembers	= rs("GoldMembershipCommission4GoldMembers")
			AdvCommission				= rs("AdvCommission")
			PageCost4FreeMembers			= rs("PageCost4FreeMembers")
			PageCost4GoldMembers			= rs("PageCost4GoldMembers")
			ReferralCommission				= rs("ReferralCommission")
			MyCommission				= rs("MyCommission")
			BannerCost4aMonth				= rs("BannerCost4aMonth")
			VisitorPackages				= rs("VisitorPackages")
			MessageOnTop						= rs("MessageOnTop")
			GoldFee					= rs("GoldFee")
			GoldMinimumPayout			= rs("GoldMinimumPayout")
			GoldFreeVisitors				= rs("GoldFreeVisitors")
			GoldBannerDays				= rs("GoldBannerDays")

			MsgBoldCost				= rs("MsgBoldCost")
			MsgHighlightCost				= rs("MsgHighlightCost")

			MsgCostNonMembers			= rs("MsgCostNonMembers")
			MsgCostFreeMembers			= rs("MsgCostFreeMembers")
			MsgCostGoldMembers			= rs("MsgCostGoldMembers")
		End If
%>
		<script language=JavaScript>
		<!--
		function Validate()
		{
			if (document.F.SiteName.value.length == 0)
			{
				alert("Please enter your Site's Name.");
				document.F.SiteName.focus();
				return false;
			}

			if (! IsNumber (document.F.MyEGold, "Please enter Your E-Gold number."))
				return false;

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

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

			if (document.F.AltPass.value.length == 0)
			{
				alert("Please enter your e-gold's alternate password.");
				document.F.AltPass.focus();
				return false;
			}

			if (! IsNumber (document.F.MinimumPayout, "Please enter the minumum payout."))
				return false;

			if (! IsNumber (document.F.MemberDelay, "Please enter delay."))
				return false;

			if (! IsNumber (document.F.AdvCommission, "Please enter commission for referring advertisers."))
				return false;

			if (! IsNumber (document.F.GoldMembershipCommission4FreeMembers, "Please enter a commission for referring GOLD members by FREE Member."))
				return false;

			if (! IsNumber (document.F.GoldMembershipCommission4GoldMembers, "Please enter commission for referring GOLD members by GOLD Member."))
				return false;

			if (! IsNumber (document.F.PageCost4FreeMembers, "Please enter a FREE Member earnings for every website."))
				return false;

			if (! IsNumber (document.F.PageCost4GoldMembers, "Please enter a GOLD Member earnings for every website."))
				return false;

			if (! IsNumber (document.F.ReferralCommission, "Please enter a Member earnings for every website visited by direct referrals."))
				return false;

			if (! IsNumber (document.F.MyCommission, "Please enter Your earnings for every visitor purchased by advertisers."))
				return false;

			if (! IsNumber (document.F.BannerCost4aMonth, "Please enter the banner cost for a month."))
				return false;

			if (! IsNumber (document.F.GoldFee, "Please enter the fee for Gold Membership."))
				return false;

			if (! IsNumber (document.F.GoldMinimumPayout, "Please enter the minimum payout for Gold Members."))
				return false;

			if (! IsNumber (document.F.GoldFreeVisitors, "Please enter the amount of FREE visitors for Gold Membership."))
				return false;

			if (! IsNumber (document.F.GoldBannerDays, "Please enter the amount of days for Gold Membership."))
				return false;

			// --- messages ---
			if (! IsNumber (document.F.MsgBoldCost, "Please enter the price for bold message."))
				return false;

			if (! IsNumber (document.F.MsgHighlightCost, "Please enter the price for highlight message."))
				return false;

			if (! IsNumber (document.F.MsgCostNonMembers, "Please enter the price per message for NON Members."))
				return false;

			if (! IsNumber (document.F.MsgCostFreeMembers, "Please enter the price per message for FREE Members."))
				return false;

			if (! IsNumber (document.F.MsgCostGoldMembers, "Please enter the price per message for GOLD Members."))
				return false;

			return true;
		}

		<% JS_IsNumber %>
		//-->
		</script>

		<form name=F action="commoninfo.asp" method=post onsubmit="return Validate()">
		<table border=0 align=center bgcolor=black cellspacing=1 cellpadding=3>
		<tr>
			<td colspan=2 class=SelectedParent align=center>
				Common Info
			</td>
		</tr>
		<tr class=Odd>
			<td>Site's name</td>
			<td>
				<input name=SiteName value="<%= SiteName %>" size=30 maxlength=25 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Your e-gold number</td>
			<td>
				<input name=MyEGold value="<%= MyEGold %>" size=30 maxlength=10 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Contact E-Mail</td>
			<td>
				<input name=ContactEMail value="<%= ContactEMail %>" size=30 maxlength=50 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Password</td>
			<td>
				<input name=Password value="<%= Password %>" size=30 maxlength=25 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Alternate e-gold password<br>(for transaction validity)</td>
			<td>
				<input name=AltPass value="<%= AltPass %>" size=30 maxlength=25 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Minimum payout ($)</td>
			<td>
				<input name=MinimumPayout value="<%= MinimumPayout %>" size=30 maxlength=10 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>How many seconds Members must to stay on a website?</td>
			<td>
				<input name=MemberDelay value="<%= MemberDelay %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Commission for referring advertisers (%)</td>
			<td>
				<input name=AdvCommission value="<%= AdvCommission %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Commission for referring GOLD members by FREE Member($)</td>
			<td>
				<input name=GoldMembershipCommission4FreeMembers value="<%= GoldMembershipCommission4FreeMembers %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Commission for referring GOLD members by GOLD Member($)</td>
			<td>
				<input name=GoldMembershipCommission4GoldMembers value="<%= GoldMembershipCommission4GoldMembers %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>FREE Member earnings for every visited website ($)</td>
			<td>
				<input name=PageCost4FreeMembers value="<%= PageCost4FreeMembers %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>GOLD Member earnings for every visited website ($)</td>
			<td>
				<input name=PageCost4GoldMembers value="<%= PageCost4GoldMembers %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Member earnings for every visited website by his direct referrals ($)</td>
			<td>
				<input name=ReferralCommission value="<%= ReferralCommission %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>My earnings for every visitor purchased by advertisers ($)</td>
			<td>
				<input name=MyCommission value="<%= MyCommission %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Banner cost for a month ($)</td>
			<td>
				<input name=BannerCost4aMonth value="<%= BannerCost4aMonth %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Visitor packages<br>(space separated)</td>
			<td>
				<input name=VisitorPackages value="<%= VisitorPackages %>" size=30 maxlength=255 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Message on the top of home page</td>
			<td>
				<input name=MessageOnTop value="<%= MessageOnTop %>" size=30 maxlength=255 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Gold Membership - Life-time fee ($)</td>
			<td>
				<input name=GoldFee value="<%= GoldFee %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Gold Membership - Mininum payout ($)</td>
			<td>
				<input name=GoldMinimumPayout value="<%= GoldMinimumPayout %>" size=30 maxlength=7 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Gold Membership - Free visitors</td>
			<td>
				<input name=GoldFreeVisitors value="<%= GoldFreeVisitors %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Gold Membership - Unlimited banner rotation (days)</td>
			<td>
				<input name=GoldBannerDays value="<%= GoldBannerDays %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Price for a bold message ($)</td>
			<td>
				<input name=MsgBoldCost value="<%= MsgBoldCost %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Price for a highlighted message ($)	</td>
			<td>
				<input name=MsgHighlightCost value="<%= MsgHighlightCost %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Price per message for NON Members ($)</td>
			<td>
				<input name=MsgCostNonMembers value="<%= MsgCostNonMembers %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Price per message for FREE Members ($)</td>
			<td>
				<input name=MsgCostFreeMembers value="<%= MsgCostFreeMembers %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr class=Odd>
			<td>Price per message for GOLD Members ($)</td>
			<td>
				<input name=MsgCostGoldMembers value="<%= MsgCostGoldMembers %>" size=30 maxlength=5 class=ClientText>
			</td>
		</tr>
		<tr>
			<td colspan=2 bgcolor=white align=center>
				<input type=submit name=Command value=Save style="width:300px">
			</td>
		</tr>
		</table>
		</form>
		<br>
<%
	End Sub
%>