<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="js" uri="net.sourceforge.jsurveyor.jsurveyorlib" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="net.sourceforge.jsurveyor.*" %>
<!-- <jsp:useBean id="Data" class="net.sourceforge.jsurveyor.DataAccess">
</jsp:useBean> -->
<js:noCache />
<js:login access="normal" />
<js:border title="jSurveyor - Questionnaires">

<tr>
	  <td class='mainmenu_headline'>Questionnaires</td>
	  <td class='mainmenu_headline_emptyfield'>&nbsp;</td>
	</tr>
	<tr>
	  <td colspan='3' class='mainmenu_blueframe'>
	    <table border='0' cellspacing='0' cellpadding='0'>
		  <tr>
		  <td class='mainmenu_workframe'> <!-- Main workframe start -->
	        <table border='0' cellspacing='0' cellpadding='0'> 
			  <tr>
			    <td class='title'>&nbsp;</td>
			    <td class='title'>Title</td>
  			    <td class='title' style='width:53%;'>Results</td>
			    </tr>
				<%
				
					ReportOutput a = new ReportOutput();
					User user = (User)session.getAttribute("userInfo");
					ArrayList questionnaireIDs = DataAccess.fetchQuestionnaires(user);
					String tdClass = "body_odd";
					for(int i = 0; i < questionnaireIDs.size(); i++) {
						if ( i%2 == 0 ) {
        	    			tdClass = "body_even";
		            	}
    		        	else {
        		    		tdClass = "body_odd";
            			}
            			Questionnaire tempQ = DataAccess.retrieveQuestionnaire(Integer.parseInt((String)questionnaireIDs.get(i)));
            			if(tempQ.getState()) {
							%>
							<tr>
							<td class='<%= tdClass %>'>&nbsp;</td>
				   			<td class='<%= tdClass %>'><a href='normal_questionnaire.jsp?questionnaireID=<%= tempQ.getQuestionnaireID() %>'><%= tempQ.getQuestionnaireName() %></a></td>
							<td class='<%= tdClass %>' style='width:53%;'><a href='servlet/ReportOutput?questionnaireID=<%= tempQ.getQuestionnaireID() %>' target='_new'>Show replies</a></td>

		 					</tr>												
							<%
						}
					}
				%>			
			</table>
		  </td> 
		  </tr>
	    </table>
      </td>
	</tr>
	<tr>
	<td>
	  <table><tr><td> <!-- Makes space between blue border and top of buttons -->
	  </td></tr>
	  </table>
	</td>
	</tr>
	
	
	<tr>
	  <td></td>
	  <td class='mainmenu_buttonline'><!--<input class='stdbutton_long' name='button' type='submit' value='Generate report'/> <input class='stdbutton' name='button' type='submit' value='Answer'/> -->
      </td>
    </tr>






</js:border>