<%@ include file="/includes.jsp" %>
<c:set var="view"  value="${calendar.currentView}"/>
<c:set var="prev"><fmt:formatDate value="${view.previous}"  pattern="dd/MM/yyyy" /></c:set>
<c:set var="next"><fmt:formatDate value="${view.next}" pattern="dd/MM/yyyy" /></c:set>
<table class="calendarTable" cellspacing="2" width="99%">
	<tr><%-- START TITLE --%>
		<td colspan="8">
			<table width="100%" cellpadding="0" cellspacing="0" class="viewTitle">
				<tr>
					<td width="33%" align="left"><a href='calendarActions.form?method=changeDate&date=${prev}'>&lt; Prev</a></td>
					<td align="center"><fmt:formatDate value="${view.previous}" type="date" pattern="MMMM yyyy" /></td>
					<td align="right" width="33%"><a href='calendarActions.form?method=changeDate&date=${next}'>Next &gt;</a></td>
				</tr>
			</table>
		</td>
	</tr><%-- END TITLE --%> 
	<tr class="dayHeaderRow"><%-- START DAY HEADERS --%>
		<td/>
		<c:forEach var="nameOfDay" items="${view.daysOfWeek}">
			<td class="dayHeaderCell" width="14%"><c:out value="${nameOfDay}"/></td>
		</c:forEach>
	</tr><%-- END DAY HEADERS --%>
	<%-- START WEEKS --%>
		<c:forEach var="week" items="${view.weeks}">
			<tr valign="top">
				<td class="weekHeaderCell">
					<c:set var="gotoWeek"> <fmt:formatDate value="${week.dateRange.start}" pattern="dd/MM/yyyy"/></c:set>
					<a href='calendarActions.form?method=changeBoth&view=week&date=${gotoWeek}'><fmt:formatDate value="${week.date}" pattern="w"/></a>
				</td>
				<%-- START DAYS --%>
				<c:forEach var="day" items="${week.days}">
					<c:set var="gotoDay"> <fmt:formatDate value="${day.dateRange.start}" pattern="dd/MM/yyyy"/></c:set>
					<td width="14%" height="100" class="dayCell dayCellCurrentMonth${day.inCurrentMonth} dayCellCurrentDay${day.today}">
						<div align="center" class="dayCellTitle dayCellTitleCurrentMonth${day.inCurrentMonth}" >
							<a class="dayCellTitle dayCellTitleCurrentMonth${day.inCurrentMonth}" href='calendarActions.form?method=changeBoth&view=day&date=${gotoDay}'><fmt:formatDate value="${day.date}" pattern="dd MMM"/></a>
							&nbsp; <a href="javascript:addEvent('${gotoDay}')" title='Add an event'><img width="12"  src="images/16x16/addEvent.png"/></a>
						</div>
						<c:forEach var="event" items="${day.events}">
							<c:set var="title">From <fmt:formatDate value="${event.startDate}" pattern="HH:mm dd/MM/yy"/> to <fmt:formatDate value="${event.endDate}" pattern="HH:mm dd/MM/yy"/></c:set>
							<fmt:formatDate value="${event.startDate}" pattern="HH:mm"/> <a title="${title}" href="javascript:editEvent('${event.editUrl}', '${event.type}')" style="color:${event.fgColour }; background-color:${event.bgColour }"><c:out value="${event.title}"/></a><br/>
						</c:forEach>
					</td>
				</c:forEach>
				<%-- END DAYS --%>
			</tr>
		</c:forEach>
	<%-- END WEEKS --%>
</table>