<!--#include virtual="/includes/topofpage.asp"-->
<%

If Session ("Process_Site") = True And Not Request("Site_Realm") = "" Then
	If Not Request("Site_Realm") = "" Then
		Session("Site_Realm") = Replace(Request("Site_Realm"), "'", "''")
		Session("Process_Site") = ""
	End If
Else

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={SQL Server};SERVER=WEBSRV01;UID=web;pwd=w3bs1t3;DATABASE=AVANTE"

Session.Timeout = 120

SQL = "Get_Realms_By_Realm @Realm_ID = '" & Replace(Session("Realm_ID"), "'", "''") & "'"
'Response.Write SQL
Set RSRealm = Conn.Execute(SQL)
Session("System_Realm") = RSRealm("Realm_ID_1")

Site_Count = 0
Do While Not RSRealm.EOF
	Select Case CInt(RSRealm("Realm_Type_ID_2"))
		Case 1	'1 admin
			Session("Admin_Realm") = RSRealm("Realm_ID_2")
		Case 2	'2 site
			Site_Count = Site_Count + 1
			Site_Realm = RSRealm("Realm_ID_2")
		Case 3	'3 merchant
			Session("Merchant_Realm") = RSRealm("Realm_ID_2")
		Case 6	'6 partner
			Session("Partner_Realm") = RSRealm("Realm_ID_2")
		Case 8	'8 staff
			Session("Staff_Realm") = RSRealm("Realm_ID_2")
	End Select

	RSRealm.MoveNext
Loop




SQL = "Get_Realm_Group @Realm_ID='" & Session("System_Realm") & "'"
' Response.Write SQL
Set RSGroup = Conn.Execute(SQL)
	Session("Entity_Group_ID") = RSGroup("Group_ID")
	Session("Entity_Name") = RSGroup("Name")
	Session("Entity_Lookup_Group") = RSGroup("Lookup_ID")
Set RSGroup = Nothing


SQL = "Get_Merchant @Group_ID = '" & Session("Entity_Group_ID") & "'"
Set RSMerchant = Conn.Execute(SQL)
    	Session("Merchant_ID") = "1" 'Vacation in Florida.com Merchant ID
Set RSMerchant = Nothing

If Site_Count = 1 Then 
	Session("Site_Realm") = Site_Realm

ElseIf Site_Count > 1 Then 
	Session ("Process_Site") = True

	%>
		<form name="form1" method="post" action = ""><Br>
		<table border="0" cellspacing="0" width="90%" align="center">
		<tr><td align="center" width="300">
		Please select a site to manage:<br><br>
			<select name="Site_Realm" id="Realm_ID" size="5" onChange="document.form1.submit();">

	<%	RSRealm.MoveFirst
		Do While Not RSRealm.EOF
			If CStr(RSRealm("Realm_Type_ID_2")) = "2"  Then
			%>
			<option value="<%=RSRealm("Realm_ID_2")%>"><%=RSRealm("Realm_Name_2")%></option>
			<%
			End IF
			RSRealm.MoveNext
		Loop
		RSRealm.MoveFirst

	%>	</select><br><br>
<!--		<input type="submit" name="submit" onClick="return if (!document.form1.Realm_ID.selected[selectedIndex] == '')" value="Click here to enter!">-->
		</td><td>&nbsp;</td></tr>
		</table>
		</form>		

	<%
	Response.End
End If

%>
<% End If %>
<html>
<STYLE>
BODY {SCROLLBAR-FACE-COLOR: #5e5ebe; SCROLLBAR-HIGHLIGHT-COLOR: #5e5ebe; SCROLLBAR-SHADOW-COLOR: #5e5ebe; SCROLLBAR-3DLIGHT-COLOR: #5e5ebe; SCROLLBAR-ARROW-COLOR:  #6666CC; SCROLLBAR-TRACK-COLOR: #E3E3E3; SCROLLBAR-DARKSHADOW-COLOR: #666666; }
</STYLE>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset rows="148,517" cols="*" border="0" framespacing="0"> 
  <frame src="/Admin/manage-top.asp" scrolling="NO" noresize frameborder="NO" name="topframe" id="topframe">
  <frameset cols="250,803" rows="*" frameborder="NO" id="bottomframe" name="bottomframe" border="0" framespacing="0"> 
    <frame src="/Admin/manage-menu.asp" name="menu" id="menu" frameborder="NO">
    <frame src="/Admin/manage-welcome.asp" name="content" id="content" application="yes" frameborder="NO" scrolling="AUTO">
  </frameset>
</frameset>
<noframes> 
<body bgcolor="#FFFFFF" text="#000000">
</body>
</noframes> 
</html>

