<%@ Import Namespace="System.IO" %>
<%@ Register TagPrefix="uc1" TagName="Trailer" Src="Trailer.ascx" %>
<%@ Register TagPrefix="uc2" TagName="Header" Src="top.ascx" %>

<%@ Page Language="c#" Codebehind="InviteUser.aspx.cs" AutoEventWireup="false" Debug="true"
    Inherits="edu.jhu.Cas.Web.InviteUser" %>

<%
    string text = Request.Params["lmessage"];
    if (null == text) text = "";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Invite User</title>
    <link href="cjobs.css" rel="stylesheet" />

    <script type="text/javascript" src="scripts\autosuggest.js"></script>

</head>
<body>
    <uc2:Header ID="Header" runat="server" />
    <p class="message">
        <%=lmessage%>
    </p>
    <p>
        Users must have checked the "Group Visibility" to be eligible.
            <br>
            This may also be modified under "My Profile". You may change your own visibility
            under <a href="ChangeDetails.aspx">Profile</a>.
    </p>
    <form runat="server">
        <b>Members of <span class="group"><%=groupName %></span></b><br />
        <p>
            <asp:ListBox ID="memberBox" Rows="20" Width="500px" SelectionMode="multiple" runat="server" />
        </p>
        <p><i>* User has not yet responded to invitation</i></p>
        <p>
            <asp:Button ID="RemoveButton" Text="Remove Selected Users" OnClick="RemoveUsers"
                ToolTip="Click here to remove selected users." runat="server" />
        </p>
        <p>Enter a user's name or userid. Use ']' to see all users.</p>
        <input style="width:150;" type="text" id="userField" name="userField" />
        <input type="button" value="Invite User" onclick="window.open('inviteuser.aspx?name=<%=groupName %>&inviteMe='+document.getElementById('userField').value,'_top','');" />        
    </form>
    <div id="autosuggest">
        <ul></ul>
    </div>
    <div id="userList" style="display: none">
        <%if (EligableUsers != null) {
              for (int x = 0; x < EligableUsers.Length; x++) {%>
        <input type="hidden" value="<%=EligableUsers[x].Name+", ["+EligableUsers[x].UserID.Trim()  + "]"%>" />
        <%}}%>
    </div>
    <uc1:Trailer ID="Trailer1" runat="server" cvsTag="$Name: v3_5_18 $" cvsRev="$Revision: 1.9 $">
    </uc1:Trailer>

    <script type="text/javascript">
	function bindEvents(){
		var tags = document.getElementById('userList').getElementsByTagName('INPUT');
		var userList = new Array(tags.Length);
		for(i=0;i<tags.length;i++)
			userList[i] = tags[i].value;
		new AutoSuggest(document.getElementById('userField'),userList);
	}
	window.onload = bindEvents;
    </script>

</body>
</html>
