<!--#include virtual="/includes/topofpage.asp"-->
<%
'Response.Write "Will be here soon! <A HREF=""javascript:history.back()"">Click here to Return</a>"
'Response.End

'  If Not Request.QueryString("ID") = "" Then Session("Group_ID") = Request.QueryString("ID")

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("conn_string")

Page="64"

Contact = False
Realm = False
Group = False

If Not Request("CID") = "" Then
	Contact = True
Elseif Not Request("RID") = "" Then
	Realm = True
Elseif Not Request("GID") = "" Then
	Group = True
End If	

Contact_ID = Request("CID")
Realm_ID = Request("RID")
Group_ID = Request("GID")

If Contact = True Then
	SQL = "Get_Contact @Contact_ID='" & Contact_ID & "'"
	Set RS = Conn.Execute(SQL)
	
	Contact_Name = RS("Name_First") & " " & RS("Name_Last")

	SQL = "Get_User @Contact_ID= '" & Contact_ID & "'"
	Set Users = Conn.Execute(SQL)

End If

User_ID = Replace(Trim(Request("uid")), "'", "''")

If Not User_ID = "" Then
	SQL = "Get_User @User_ID='" & User_ID & "'"
'	Response.Write SQL
	Set Get_User = Conn.Execute(SQL)
	Create_Date = Get_User("User_CreateDate")
	User_Name = Get_User("User_Name")
	Set Get_User = Nothing
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">






<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layeRS1&&i<d.layeRS1.length;i++) x=MM_findObj(n,d.layeRS1[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function SubmitForm() {
var errmsg='';
//if (form1.Name_First.value=='') errmsg=errmsg+'Must Specify a First Name\n';
//if (form1.Name_Last.value=='') errmsg=errmsg+'Must Specify a Last Name\n';
//if (form1.Address_1.value=='') errmsg=errmsg+'Must Specify An Address\n';
//if (form1.City.value=='') errmsg=errmsg+'Must Specify a City\n';
//if (form1.State.value=='') errmsg=errmsg+'Must Specify a State\n';
//if (form1.Country.value=='') errmsg=errmsg+'Must Specify a Country\n';
//if (form1.Zip.value=='') errmsg=errmsg+'Must Specify a Zip Code\n';
//if (form1.Email_Home.value=='' && form1.Email_Work.value=='' && form1.Email_Other.value=='') errmsg=errmsg+'Must Specify At Least One Email Address\n';

//if (form1.createuser.checked) {
//  if (!form1.User_PWD.value == form1.User_PWD_2.value) errmsg=errmsg+'Passwords do not match. Please re-type your password\n'
//  if (form1.User_PWD.value == '') errmsg += 'Must specify a Password\n'
//  if (form1.User_Name.value == '') errmsg += 'Must choose a User Name\n'
//  if (!document.form1.Key_Name[0].checked && !document.form1.Key_Name[1].checked && !document.form1.Key_Name[2].checked) errmsg += 'Must select an access type (i.e., Administrator)\n'
//}

if (errmsg) alert(errmsg);
else form1.submit();
}


function createuser() {
	var errmsg='';
	if (errmsg) alert(errmsg);
	else {
		form1.act.value='New';
		form1.action='user_create.asp';
		form1.submit();
	}
}

function manageuser() {
	var errmsg='';
	if (errmsg) alert(errmsg);
	else {
		form1.act.value='';
		form1.action='user_create.asp';
		form1.submit();
	}
}

function managechain() {
	var errmsg='';
	if (errmsg) alert(errmsg);
	else {
		form1.action='user_keychain.asp';
		form1.submit();
	}
}

function toggle_div(selobj, divID) {

	var divobj = MM_findObj(divID);

	if (selobj.value=='') {
	divobj.style.display='none';
	}

	if (selobj.value!='') {
	divobj.style.display='inline';
	}

	return true;
}

function userchange () {

	form1.submit();
//	toggle_div(MM_findObj('uid'), 'userdiv');
}

//-->
</SCRIPT>

<link rel="stylesheet" href="/Style-sheets/standard-input-form.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/headline.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/galley-text-indent.css" type="text/css">
<link rel="stylesheet" href="/Style-sheets/Lodging-display.css" type="text/css">
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="return toggle_div(MM_findObj('uid'), 'userdiv');">
<FORM action="" method=post id=form1 name=form1>
<input type="hidden" name="cid" value="<%=Contact_ID%>">
<input type="hidden" name="rid" value="<%=Realm_ID%>">
<input type="hidden" name="gid" value="<%=Group_ID%>">
<input type="hidden" name="act" value="">
<Br>  
<table border="0" cellspacing="0" cellpadding="0" width="590" style="WIDTH: 590px" align="center" bgcolor="#e7e7e7">
  <tr>
	<td width="50%"></td>
	<td width="1"></td>
	<td width="49%"></td>
	<td width="4"></td>
  </tr>
  <tr> 
    <td colspan="4" valign="top" align="center" bgcolor="#6699cc">&nbsp;&nbsp;<font color="#f3f3f3"><b>User Administration for: 
    <%
		If Contact = True Then 
			Response.Write Contact_Name & "</b> (Contact Users)&nbsp;&nbsp;"
		ElseIf Realm = True Then 
			Response.Write Realm_Name & "</b> (Realm Users)&nbsp;&nbsp;"
		ElseIf Group = True Then 
			Response.Write Group_Name & "</b> (Group Users)&nbsp;&nbsp;"
		End If
    %></font>
    </td>
  </tr>
  <tr>
	<td bgcolor="#e7e7e7" colspan="1"><img src="/images/shim.gif" height="1" width="1"></td>
	<td bgcolor="#e7e7e7" colspan="3"><img src="/images/shim.gif" height="1" width="1"></td>
  </tr>
  <tr> 
    <td rowspan="2" valign="top" align="center" bgcolor="#5599cc"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Select a User to Manage</b></font><font color="#ffffff" size="2"><br>
    <select name="uid" SIZE="5" onChange="userchange();" style="{width:98%}">
<% If Not Users.EOF Then 
	Do While Not Users.EOF
		%>
		<option value="<%=Users("User_ID")%>"
		<% If CStr(Users("User_ID")) = CStr(Request("uid")) Then Response.Write " selected" %>
		><%=Users("User_Name")%></option>
		<%
		Users.MoveNext
	Loop
 Else %>
	<option value="">No users have been defined or can be found.</option>
	<option value="">Please feel free to create one.</option>
<% End If %>
    </select><br><img src="/images/shim.gif" height="3" width="1"></td>
	<td><img src="/images/shim.gif" height="1" width="1"></td>
	<td align="right" valign="top" height="3" bgcolor="#cccccc"><table border="0" cellspacing="0" cellpadding="0" width="100%">
		<tr><td valign="top" align="left">&nbsp;&nbsp;<a href="javascript:removeuser();"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#000099">Remove this User</font></b></font></a></td>
		<td valign="top" align="right"><a href="javascript:createuser();"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#000099">Create a new User</font></b></font></a>&nbsp;
	</td></tr></table></td>
	<td bgcolor="#cccccc">&nbsp;</td>
  </tr>
  <tr>
	<td><IMG height=3 src="../images/shim.gif" width=1></td>
	<td align="right" valign="bottom" bgcolor="#e7e7e7"><div class="manage-menu">
Created: <input size="20" type="text" name="na" value="<%=Create_Date%>" style="{background-color:#e7e7e7;}" readonly>&nbsp;<br>
User Name: <input size="20" type="text" name="user_name" value="<%=User_Name%>" style="{background-color:#e7e7e7;}" readonly>&nbsp;<br>
Password: <input size="20" type="text" name="text" value="<% If Not User_ID = "" Then Response.Write "******" %>" style="{background-color:#e7e7e7;}" readonly>&nbsp;<br>
</div></td>
	<td bgcolor="#e7e7e7"><IMG height=3 src="../images/shim.gif" width=4></td>
  </tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="590" style="WIDTH: 590px" align="center" bgcolor="#e7e7e7">
  <tr>
	<td width="50%"></td>
	<td width="1"></td>
	<td width="49%"></td>
	<td width="4"></td>
  </tr>
  <tr>
	<td colspan="4"><div id="userdiv" name="userdiv" style="{ width:100%;height:100%;align:center;display:none;}">
		<table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#e7e7e7">
			<tr>
				<td width="5%"></td>
				<td width="55%"></td>
				<td></td>
			</tr>
			<tr><td colspan="3" bgcolor="#e7e7e7"><IMG height=6 src="../images/shim.gif" width=4></td></tr>
			<tr><td colspan="3" bgcolor="#e1e1e1"><IMG height=6 src="../images/shim.gif" width=4></td></tr>
			<tr><td bgcolor="#e1e1e1" class="manage-menu" colspan="3" align="center"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td class="manage-menu" width="50%" align="left">&nbsp;<b>User is Active in:</b></td><td width="50%" align="right"><a href="javascript:manageuser();"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#000099">Manage User</font></b></font></a>&nbsp;&nbsp;</td></tr></table></td></tr>
			<tr><td colspan="3" bgcolor="#cccccc"><IMG height=2 src="../images/shim.gif" width=4></td></tr>
			<tr><td colspan="3">&nbsp;</td></tr>
			<tr><td></td><td colspan="2" class="manage-menu"><%
' Realm Listing
	SQL = "Get_User_Realms @User_ID='" & User_ID & "'"
	Set Realm = Conn.Execute(SQL)
	If Not Realm.EOF Then
		Do While Not Realm.EOF
			%>
				<%=Realm("Realm_Name")%><input type="hidden" name="Realms" value="<%=Realm("Realm_ID")%>"><br>
			<%
			Realm.MoveNext
		Loop
		Realm.MoveFirst
	Else
		%>
		<b>No Realm Assignments Made</b>
		<%
	End If

			%></td></tr>
			<tr><td colspan="3">&nbsp;</td></tr>

			<tr><td colspan="3" bgcolor="#e1e1e1"><IMG height=6 src="../images/shim.gif" width=4></td></tr>
			<tr><td bgcolor="#e1e1e1" class="manage-menu" colspan="3" align="center"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td class="manage-menu" width="50%" align="left">&nbsp;<b>User's Key Chain:</b></td><td width="50%" align="right"><a href="javascript:managechain();"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#000099">Manage Permissions</font></b></font></a>&nbsp;&nbsp;</td></tr></table></td></tr>
			<tr><td colspan="3" bgcolor="#cccccc"><IMG height=2 src="../images/shim.gif" width=4></td></tr>
			<tr>
				<td colspan="3">&nbsp;</td>
			</tr>
<% If Realm.EOF Then %>
			<tr>
				<td></td><td colspan="2" class="manage-menu" align="left"><b>No Permissions Defined</b></td>
			</tr>
			<tr>
				<td></td><td colspan="2" class="manage-menu" align="left">&nbsp;</td>
			</tr>
<% Else %>
	<% Do while Not Realm.EOF %>
	
			<tr>
				<td colspan="2" class="manage-menu" align="left"><div style="{ text-decoration: underline; }" class="manage-menu"><b>&nbsp;<%=Realm("Realm_Name")%></b></div></td>
				<td class="manage-menu">&nbsp;</td>
			</tr>
		<%
			SQL = "Get_User_Key_Chain @User_ID='" & User_ID & "', @Realm_ID='" & Realm("Realm_ID") & "'"
			Set KC = Conn.Execute(SQL)
			If KC.EOF Then
				%>
				<tr>
					<td class="manage-menu" valign="top" align="right"><img src="../images/shim-000000.gif" height="14" width="1"></td>
					<td colspan="2" class="manage-menu" valign="bottom" align="left"><img src="../images/shim-000000.gif" height="1" width="15">&nbsp;No Permissions Defined for this Realm</td>
				</tr>
				<%
			Else
				Do While Not KC.EOF
					%>
					<tr>
						<td class="manage-menu" valign="top" align="right"><img src="../images/shim-000000.gif" height="14" width="1"></td>
						<td colspan="2" class="manage-menu" valign="bottom" align="left"><img src="../images/shim-000000.gif" height="1" width="15">&nbsp;<%=KC("Key_Ring_Name")%> (<%=KC("Key_Ring_Desc")%>)</td>
					</tr>
					<%					
					KC.MoveNext
				Loop
			End If
		%>
			<tr><td colspan="3">&nbsp;</td></tr>
	<% Realm.MoveNext
	Loop %>

<% End If %>
		</table></div>
<!--
			<tr>
				<td colspan="2" class="manage-menu" align="left"><div style="{ text-decoration: underline; }" class="manage-menu"><b>&nbsp;Vacation in Florida - Site</b></div></td>
				<td class="manage-menu">&nbsp;</td>
			</tr>
			<tr>
				<td class="manage-menu" valign="top" align="right"><img src="../images/shim-000000.gif" height="18" width="1"></td>
				<td colspan="2" class="manage-menu" valign="bottom" align="left"><img src="../images/shim-000000.gif" height="1" width="30"> Whatever Key</td>
			</tr>
			<tr>
				<td class="manage-menu" valign="top" align="right"><img src="../images/shim-000000.gif" height="14" width="1"></td>
				<td colspan="2" class="manage-menu" valign="bottom" align="left"><img src="../images/shim-000000.gif" height="1" width="30"> Whatever Key</td>
			</tr>
-->
	</td>
  </tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="590" style="{ WIDTH: 590px; HEIGHT=4px}" align="center" bgcolor="#e7e7e7">
  <tr>
	<td width="50%"></td>
	<td width="1"></td>
	<td width="49%"></td>
	<td width="4"></td>
  </tr>
  <tr><td colspan="4" bgcolor="#e7e7e7"><img src="/images/shim.gif" width="1" height="4"></td>
  </tr>
 </table>
</FORM>
</body>
</html>


