<%@ page import="java.util.*" %>
<!-- Authors: Jason Fillo and Peter Deschere -->

<html>
 <head>
   <title>Bulletin Board - Powered by $Money</title>
 </head>

 <body>
 <%
	String name = (String)request.getAttribute("name");
	if(name == null) {
 %>

  <script type="text/javascript">
  var answer = alert ("Error logging in.  Check your username and password.")
  window.location="login.jsp"
  </script>

  
  <%	   
        }
	else {
	out.print(name);
	out.print("<br>");
	String r = request.getSession(false).toString();
	out.print(r);
 %>
 
	<h3>Topics</h3>

	<form method="post" action="ViewTopic.do">
 <%
	List topics = (List)request.getAttribute("topics");
	Iterator it = topics.iterator();
	while(it.hasNext()) {
		String currentTopic = (String)it.next();
 %>
	      <input type="radio"
	             name="topicselected"
                     value="<%=currentTopic%>"/><%=currentTopic%><br>

 <%
            }
	    %><input type="submit" value="View Topic"/>
	      <input type="hidden" name="name" value="<%= name%>"/>
	      </form>
	    <%
	}
 %>

    <h3>Post New Topic</h3>
    <form method="post" action="PostTopic.do">
    <input type="hidden" name="name" value="<%= name%>"/>
    
	<table>
	<tr>
	  <td>New Topic Name</td>
	  <td><input type="text" name="topicname"></td>
	</tr>
	<tr>
	  <td colspan=2 align=center>
		<input type="submit" value="Post New Topic"/>
	  </td>
	</tr>
	</table>
    </form>

	
 <p>
	<form method="post" action="login.jsp">
		<input type="submit" value="logout"/>
	</form>
 </p>
 </body>
</html>