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

<html>
<head>

<script type='text/javascript' src='./javascripts/prototype.js'></script>
<script type='text/javascript' src='./javascripts/scriptaculous.js'></script>

<script type="text/javascript">
//<![CDATA[
	function ShowRegistered() {
		if ($('register').checked)
			listElem = $$('.isRegistered').invoke('blindDown');
		else
			listElem = $$('.isRegistered').invoke('blindUp');
	}
	
	function ShowNotRegistered() {
		if ($('notregister').checked)
			listElem = $$('.notRegistered').invoke('blindDown');
		else
			listElem = $$('.notRegistered').invoke('blindUp');
	}
	
	function ShowOngoing() {
		if ($('ongoing').checked)
			listElem = $$('.confPast').invoke('blindUp');
		else
			listElem = $$('.confPast').invoke('blindDown');
	}
//]]>
</script>

</head>
<body>

<h4 class="title">Conference's list</h4>

	<c:if test="${ac != null}">
		<p class="formOk">
		<c:choose>
			<c:when test="${ac == 2}"><fmt:message key="message.account.validate" /></c:when>
			<c:when test="${ac == 1}"><fmt:message key="message.account.maj" /></c:when>
		</c:choose>
		</p>
	</c:if>

	<c:if test="${errorMessage != null}">
		<div class="errorBox">
		<c:choose>
			<c:when test="${errorMessage == 1}"><fmt:message key="message.error.noconferenceforthisid" /></c:when>
			<c:when test="${errorMessage == 2}"><fmt:message key="message.error.noconferenceid" /></c:when>
			<c:otherwise><fmt:message key="message.error.conferenceerror" /></c:otherwise>
		</c:choose>
		</div>
	</c:if>

	<c:choose>
		<c:when test="${empty listConference}">
		<div class="warningBox">
			Sorry, there is no conference at the moment.
		</div>
		</c:when>
		<c:otherwise>
			<p class="formHelp">
				Choose a conference
			</p>
			
			<table width="100%">
			<tr>
				<td width="7%">Show</td>
				<td width="93%">
					<authz:authorize ifNotGranted="ROLE_ANONYMOUS">
						<input id="register" type="checkbox" name="register" value="Register" onchange="ShowRegistered()" checked="checked"> Conference you are registered in<br />
						<input id="notregister" type="checkbox" name="notregister" value="NotRegister" onchange="ShowNotRegistered()" checked="checked"> Conference you are not registered in<br />
					</authz:authorize>	
					<input id="ongoing" type="checkbox" name="ongoing" value="Upcoming" onchange="ShowOngoing()"> Only upcoming conferences<br />
				</td>
			</tr>
			</table>
			
    		<c:forEach items="${listConference}" var="conference">
    			<c:set var="varName" value="false" />
				<c:forEach items="${listRole}" var="role">
					<c:if test="${conference.id == role.conference.id and varName == 'false' }">
						<c:set var="varName" value="true" />
					</c:if>
				</c:forEach>
				<c:choose>
					<c:when test="${varName == 'true'}">
						<c:choose>
						<c:when test="${conference.currentPhase == 'PAST'}">
							<div class="conferenceBloc cbb isRegistered confPast">
							<h2>
								${conference.title} - In this conference you are:
								<c:forEach items="${listRole}" var="role">
								<c:if test="${conference.id == role.conference.id}">
									<span style="color: #8D0000; text-transform: capitalize;">${fn:toLowerCase(role.type)}</span>				
								</c:if>
								</c:forEach>
							</h2>
							<b>Description:</b> ${conference.description}<br />
							<center>
								<a href="<c:url value="/chooseConference.htm?idConf=${conference.id}" />">Select</a><br />
							</center>
							</div>
						</c:when>
						<c:otherwise>
							<div class="conferenceBloc cbb isRegistered">
							<h2>
								${conference.title} - In this conference you are:
								<c:forEach items="${listRole}" var="role">
								<c:if test="${conference.id == role.conference.id}">
									<span style="color: #8D0000; text-transform: capitalize;">${fn:toLowerCase(role.type)}</span>				
								</c:if>
								</c:forEach>
							</h2>
							<b>Description:</b> ${conference.description}<br />
							<center>
								<a href="<c:url value="/chooseConference.htm?idConf=${conference.id}" />">Select</a><br />
							</center>
							</div>
						</c:otherwise>
						</c:choose>
					</c:when>
					<c:otherwise>
						<c:choose>
						<c:when test="${conference.currentPhase == 'PAST'}">
							<div class="conferenceBloc cbb notRegistered confPast">
								<h2>${conference.title} - You haven't any role in this conference</h2>
								<b>Description:</b> ${conference.description}<br />
								<center>
									<a href="<c:url value="/chooseConference.htm?idConf=${conference.id}" />">View details</a><br />
								</center>
							</div>
						</c:when>
						<c:otherwise>
							<div class="conferenceBloc cbb notRegistered">
								<h2>${conference.title} - You haven't any role in this conference</h2>
								<b>Description:</b> ${conference.description}<br />
								<center>
									<a href="<c:url value="/chooseConference.htm?idConf=${conference.id}" />">View details</a><br />
								</center>
							</div>
						</c:otherwise>
						</c:choose>
					</c:otherwise>
				</c:choose>
			</c:forEach>
    	</c:otherwise>
	</c:choose>
</body>
</html>
