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

<html>
<head>

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

<script type="text/javascript">
	function HideRegistered() {
		var listElem = $$('.isRegistered');
		for (var i = 0; i < listElem.length; i++) {
			if (listElem[i].visible())  	
  				listElem[i].style.display = "none";
  			else
  				listElem[i].style.display = "";
  		}
	}
	
	function HideNotRegistered() {
		var listElem = $$('.notRegistered');
		for (var i = 0; i < listElem.length; i++) {
			if (listElem[i].visible())  	
  				listElem[i].style.display = "none";
  			else
  				listElem[i].style.display = "";
  		}
	}
</script>

</head>
<body>

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

	<c:if test="${ac != null}">
		<p class="formHelp">
		<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="errorBox">
			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%">Hide</td>
				<td width="93%"><input type="checkbox" name="register" value="Register" onchange="HideRegistered()"> Conference you are registered in<br />
					<input type="checkbox" name="notregister" value="NotRegister" onchange="HideNotRegistered()"> Conference you are not registered in
				</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'}">
						<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}">
									${fn:toLowerCase(role.type)}				
								</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 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:forEach>
    	</c:otherwise>
	</c:choose>
	

	<br />


<a href="<c:url value="main.htm"/>">Home</a>

</body>
</html>
