<%@ include file="/includes.jsp" %>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<tiles:importAttribute /><%--This imports all tiles atributes to page --%>
<c:if test="${disabled eq null }">
	<c:set var="disabled" value="false"/>
</c:if>
<c:set var="fieldNameForUseInMap" value="${fieldName}"/>
<table cellpadding="2" cellpadding="0" class="buttonGroup">
	<tr>
		<td>
			<smvc:select disabled="${disabled}" path='multiSelect[${fieldName}]' id="${fieldName}_${listName}" >
				<smvc:option value="emptyPlaceHolder">&nbsp;</smvc:option>
				<webapp:namedList id="nl" domain="${listDomain}" name="${listName}" filterHospCode="${filterHospitalCode}" nlFromFormDefinition="${namedListMap[listDomain][listName]}"/>
				<c:forEach var="pair" items="${nl.pairs}">
				 	<c:set var="addOption" value="yes"/>
					<c:forEach var="value" items="${consultationNoteForm.view.note.getStringValues(fieldNameForUseInMap)}">
					  	<c:if test="${value eq pair.first}" >
					  		<c:set var="addOption" value="no"/>
					  	</c:if>
					</c:forEach>
					<c:if test="${addOption eq 'yes'}"> <smvc:option value="${pair.first}"><c:out value="${pair.second}"/></smvc:option></c:if>
				</c:forEach>
			</smvc:select>
		</td>
	</tr>
	<tr>
		<td align="center" height="100%">
			<table cellpadding="0" height="100%" width="100%">
				<tr>
					<td align="center">
						<input type="button" value="Add" title="Click to add selected items to list" onclick="moveSelection('<c:out value="${fieldName}"/>_<c:out value="${listName}"/>', '<c:out value="${fieldName}"/>')"/>
					</td>
					<td  align="center">
						<input type="button" value="Remove" title="Click to remove selected items from list" onclick="moveSelection('<c:out value="${fieldName}"/>', '<c:out value="${fieldName}"/>_<c:out value="${listName}"/>')"/>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<smvc:select disabled="${disabled}" multiple="multiple" path='multiValue[${fieldName}]' id="${fieldName}"  size="${rows}">
				<c:forEach var="value" items="${consultationNoteForm.view.note.getStringValues(fieldNameForUseInMap)}">
					<c:forEach var="pair" items="${nl.pairs}">
						<c:if test="${pair.first eq value}">
							<smvc:option value="${pair.first}"><c:out value="${pair.second}"/></smvc:option>
						</c:if>
					</c:forEach>
				</c:forEach>
			</smvc:select></td>																	
	</tr>
</table>