<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/taglib.jsp"%>
<h2><em>日历</em></h2>

<table id="calendar">
	<fmt:formatDate var="month" value="${calendar.month}" pattern="yyyy-MM"/>
	<caption><fmt:formatDate value="${calendar.month}" pattern="yyyy年M月"/></caption>
	<thead>
		<tr>
			<th abbr="星期日" scope="col" title="星期日">日</th>
			<th abbr="星期一" scope="col" title="星期一">一</th>
			<th abbr="星期二" scope="col" title="星期二">二</th>
			<th abbr="星期三" scope="col" title="星期三">三</th>
			<th abbr="星期四" scope="col" title="星期四">四</th>
			<th abbr="星期五" scope="col" title="星期五">五</th>
			<th abbr="星期六" scope="col" title="星期六">六</th>
		</tr>
	</thead>

	<tfoot>
		<tr>
			<c:if test="${calendar.prevMonth!=null}">
			<fmt:formatDate var="prevMonth_1" value="${calendar.prevMonth}" pattern="yyyy-MM"/>
			<fmt:formatDate var="prevMonth_2" value="${calendar.prevMonth}" pattern="yyyy年M月"/>
			<td abbr="<c:out value="prevMonth_2"/>" colspan="3" id="prev"><a href="<c:url value="/articles.do?method=byArchive&date=${prevMonth_1}"/>" title="浏览<c:out value="${prevMonth_2}"/>的文章"
				style="font-weight:normal;font-size:10px;">&laquo;<c:out value="${prevMonth_2}"/></a></td>
			<td class="pad">&nbsp;</td>
			</c:if>
			<c:if test="${calendar.nextMonth!=null}">
			<fmt:formatDate var="nextMonth_1" value="${calendar.nextMonth}" pattern="yyyy-MM"/>
			<fmt:formatDate var="nextMonth_2" value="${calendar.nextMonth}" pattern="yyyy年M月"/>
			<td abbr="<c:out value="${nextMonth_2}"/>" colspan="3" id="next"><A HREF="<c:url value="/articles.do?method=byArchive&date=${nextMonth_1}"/>" title="浏览<c:out value="${nextMonth_2}"/>的文章"
				style="font-weight:normal;font-size:10px;"><c:out value="${nextMonth_2}"/>&raquo;</A></td>
			</c:if>
		</tr>
	</tfoot>

	<tbody>
		<tr>
			<c:if test="${calendar.backOffsetDays>0}"><td colspan="<c:out value="${calendar.backOffsetDays}"/>" class="pad">&nbsp;</td></c:if>
			<c:forEach var="day" begin="1" end="${calendar.days }">
			<c:choose>
				<c:when test="${calendar.map[day]!=null}">
					<td><a href="<c:url value="/articles.do?method=byArchive&date=${month}-${day}"/>"><c:out value="${day}"/></a></td>
				</c:when>
				<c:otherwise>
					<td><c:out value="${day}"/></td>
				</c:otherwise>
			</c:choose>
			<c:if test="${(day+calendar.backOffsetDays)%7==0&&day!=calendar.days}"></tr><tr></c:if>	
			</c:forEach>
			<c:if test="${calendar.forwardOffsetDays>0}"><td class="pad" colspan="<c:out value="${calendar.forwardOffsetDays}"/>">&nbsp;</td></c:if>
		</tr>
	</tbody>
</table>
