<%@ include file="/WEB-INF/decorators/include.jsp"%>

<html>
<head>
</head>
<body>

<h4 class="title"> Share your opinion</h4>

	<c:choose>
	<c:when test="${empty listMessage}">
		<div class="warningBox">
    		There is no message for this article at the moment.
    		You can post a message if you want using the form below.
    	</div>
	</c:when>
	<c:otherwise>
		<div>
		<table style="width: 100%">
			<tr bgcolor="#FFCE64">
				<td width="15%" align="center"><b>Date</b></td>
				<td width="25%" align="center"><b>Author</b></td>
				<td width="60%" align="center"><b>Message</b></td>	
			</tr>
		<c:forEach items="${listMessage}" var="message" varStatus="status">
			<c:choose>
				<c:when test="${(status.index%2)==0}">
					<tr bgcolor="white">
					<td width="15%" align="center" valign="top">
					<fmt:formatDate value="${message.dateMessage}" dateStyle="short" />
					</td>
					<td width="25%" align="center" valign="top">${message.user.firstName} ${message.user.lastName}</td>
					<td width="60%" align="left"><b>${message.title}:</b><br />${message.message}</td>
					</tr>
				</c:when>
				<c:otherwise>
					<tr bgcolor="#FDF2D8">
					<td width="15%" align="center" valign="top">
					<fmt:formatDate value="${message.dateMessage}" dateStyle="short" />
					</td>
					<td width="25%" align="center" valign="top">${message.user.firstName} ${message.user.lastName}</td>
					<td width="60%" align="left"><b>${message.title}</b><br />${message.message}</td>
					</tr>	
				</c:otherwise>
			</c:choose>

		</c:forEach>
		</table>
		</div>
		<hr />
	</c:otherwise>
	</c:choose>



<form:form method="post" commandName="addMessage" id="account_data">

<p class="legend">Add a message</p>

<fieldset>
	<div>
		<form:label path="title">Title</form:label>
		<form:input path="title"/>
	</div>
	<div>
		<form:label path="message">Your message</form:label>
		<form:textarea path="message" cols="60" rows="10" />
		<span class="formError"><form:errors path="message" /></span>
	</div>
</fieldset>

	<input type="submit" value="Send" />

</form:form>
<br />
<a class="back_link" href="main.htm">Main</a>
</body>
</html>