<!-- Written by Sukhwinder Singh (ssruprai@hotmail.com -->
<%-- Written by Sukhwinder Singh (ssruprai@hotmail.com --%>

<%@ page errorPage="error.jsp" %>
<%
	String nickname = (String)session.getAttribute("nickname");
	if (nickname != null) {
		response.sendRedirect("chat.jsp");
	}
%>
<HTML>
  <HEAD>
    <TITLE>
	  <%= getServletContext().getInitParameter("leagueName") %> Chat - Login
    </TITLE>
	 <META http-equiv="pragma" content="no-cache">
	 <meta name="Author" content="Sukhwinder Singh (ssruprai@hotmail.com">	
	 <script>
	 if(window.top != window.self) {
		 window.top.location = window.location;
	 }
	 </script>
	 <LINK rel="stylesheet" href="<%=request.getContextPath()%>/chat.css">
	 <META name="author" content="Sukhwinder Singh (ssruprai@hotmail.com)">
	</HEAD>
	<BODY bgcolor="#FFFFFF" onLoad="document.login.nickname.focus();">
	<%@ include file="/header.jsp" %>
    <TABLE width="40%" border="0" cellspacing="1" cellpadding="1" align="center">
      <%
      String d=request.getParameter("d");
      String n=request.getParameter("n");
      String ic = request.getParameter("ic");
		
          if (d != null && d.equals("t")) {
      %>
      <TR>
        <TD>
          <TABLE width="100%" border="0" cellspacing="1" cellpadding="1" align="center">
            <TR>
              <TD colspan="2" align="center">
                <SPAN class="error">Nickname exists</SPAN><BR>
              </TD>
            </TR>
				<TR>
              <TD colspan="2">
                Nickname <B><%=n%></B> has already been taken please select some other nick.
              </TD>
            </TR>
          </TABLE>
        </TD>
      </TR>
      <%
        } else if (ic != null && ic.equals("t")) {
      %>
      <!-- 
      <TR>
        <TD colspan="2">
          <TABLE width="100%" border="0" cellspacing="1" cellpadding="1" align="center">
            <TR>
              <TD colspan="2" align="center">
                <SPAN class="error">Incomplete information</SPAN>
              </TD>
            </TR>
				<TR>
              <TD colspan="2">
                <b>Team</b> and <b>Nickname</b> must be entered and nickname must be atleast <b>4</b> characters long and must not contain any <b>space</b>.
              </TD>
            </TR>
          </TABLE>
        </TD>
      </TR>
      -->
      <%
        }
      %>
      <TR>
        <TD colspan="2" class="panel">
          <FORM name="login" method="post" action="<%=request.getContextPath()%>/servlet/login">
            <TABLE width="100%" border="0">
            <!-- 
              <TR>
                <TD width="30%" class="white">
                  Nickname
                </TD>
                <TD width="70%">
                  <INPUT type="text" name="nickname" size="15">
                </TD>
              </TR>
              <TR>
                <TD width="30%" class="white">
                  Team
                </TD>
                <TD width="70%">
                  <INPUT type="text" name="team" size="5">
                </TD>
              </TR>
              -->
              <tr>
              <td>
              		<select name="team" id="team">
						 <%
						 String teamData = getServletContext().getInitParameter("teamData");
						 String teamDisplay = getServletContext().getInitParameter("teamDisplay");
						 String[] tDaFlds = teamData.split(",");
						 String[] tDiFlds = teamDisplay.split(",");
						 // add test to ensure lengths are identical
						 for (int i = 0; i < tDaFlds.length; i++) {
							 out.write("<option value=\""+tDaFlds[i]+"\">"+tDiFlds[i]+"</option>");
						 }
						 %>
					</select>
			  </td>
              </tr>
              <TR>
                <TD>
                 &nbsp;
                </TD>
                <TD>
                  <INPUT type="submit" name="Submit" value="Submit">
                </TD>
              </TR>
            </TABLE>
          </FORM>
        </TD>
      </TR>
    </TABLE>
  </BODY>
</HTML>
