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

	Dim CID, URL

	CID = Str2Num(Request.Querystring("CID"))

	If CID > 0 Then
		Click
	Else
		PageBegin
		LinkList
		PageEnd
	End If


	Sub Click()

		If DateDiff("s", Session(Prefix & "LastVisit"), Now) < MemberDelay Then
%>
<html>
<head>
<title><%= SiteName %></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel=stylesheet href=common.css>
</head>
<body>
<p align=center class=PageText>
<br>
Our system indicates that you are clicking links too quickly. Please 
give that site the time and respect the advertiser deserves.<br>
Please wait <%= MemberDelay %> seconds before clicking on the next 
link. You may now close this window.
</p>
</body>
</html>
<%
			Exit Sub
		End If

		OpenConnection

		Dim rsLinks
		Set rsLinks = DBC.Execute("SELECT SiteURL FROM Campaigns WHERE CID = " & CID)

		If rsLinks.EOF Then
			URL = "advertise.asp"
		Else
			URL = rsLinks("SiteURL")
		End If

		Session(Prefix & "LastVisit") = Now()

		rsLinks.Close
		Set rsLinks = Nothing
%>
<html>
<head>
<title><%= SiteName %></title>
<frameset rows="82,*" border=0>
<frame name=main src=top.asp?CID=<%= CID %> border=0>
<frame name=content src="<%= URL %>">

<noframes>
<body>
Your browser doesn't support frames!
</body>
</noframes>
</frameset>
</head>
</html>
<%
	End Sub


	Sub LinkList()

		Dim rsLinks, i
%>
		<a href=memberaccount.asp>Member's Area</a>&nbsp;&nbsp;&nbsp;
		<a href=member.asp?Command=LogOut>Log Out</a>

		<table border=0 cellpadding=3 cellspacing=1 align=center>
		<tr class=Title>
			<td align=center>
				Paid Clicks
			</td>
		</tr>
<%
		OpenConnection

		Set rsLinks = DBC.Execute("SELECT CID, SiteTitle FROM Campaigns " & _
					"WHERE Approved = 1 AND VisitsLeft > 1 AND CID NOT IN (-1" & Replace(Session(Prefix & "VisitedCampaigns"), " ", ",") & ") " & _
					"ORDER BY CID DESC")

		If rsLinks.EOF Then
			Application(Prefix & "PaidClicksStatus") = "<font color=red>No websites in Paid Clicks section !</font><br><br>"
%>
		<tr class=Odd>
			<td align=center>
				At the moment we have no websites. Please come back soon or check out our <a href=advertise.asp>Advertise</a> section. 
			</td>
		</tr>
<%
		Else
			Application(Prefix & "PaidClicksStatus") = ""
%>
		<tr class=Odd>
			<td align=center>
				All links open in new window!
			</td>
		</tr>
<%
			i = 1

			Do While Not rsLinks.EOF
				Response.Write "<tr class=Odd><td>" & i & ". <a href=list.asp?CID=" & rsLinks("CID") & " target=_blank>" & rsLinks("SiteTitle") & "</a></td></tr>"

				i = i + 1
				rsLinks.MoveNext
			Loop
		End If
%>
		</table>
<%
	End Sub
%>