<%@ include file="/includes.jsp" %>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<tr>
	<td class="label">Traffic Light</td>
	<td class="input">
	</td>
</tr>
<c:set var="cf" value="${formObjectForm.formField.parent.parent.parent}"/>
	<tr>
		<td></td>
		<td><img src="../images/16x16/help.png" alt="Help" border="0"/> Display something depending on another field's value.<br/>This can be used to show a risk assessment score or banding,<br/>depending on the range of values the other field has.<br/></td>
	</tr>
	<tr>
		<td class="label">Test value of other field:</td>
		<td class="input">
			<smvc:select path="formField.referencedField">
				<c:forEach var="otherObj" items="${cf.toFlatList()}">
					<c:if test="${(otherObj.type eq 5) && (otherObj.name ne formObjectForm.formField.name)}">
						<c:if test="${otherObj.inputType eq 2 or otherObj.inputType eq 3 or otherObj.inputType eq 5 }">
							<c:choose>
								<c:when test="${otherObj.inputType eq 5}">
									<c:if test="${not empty (otherObj.optionsMapDomain) && not empty (otherObj.optionsMapName)}">
									   <webapp:namedList id="nl" domain="${otherObj.optionsMapDomain}" name="${otherObj.optionsMapName}" filterHospCode="${formObjectForm.formField.filterHospitalCode}"/>
										<c:set var="isNumericList" value="true"/>
										<c:forEach var="pair" items="${nl.pairs}">
											<c:if test="${isNumericList eq true }">
												<c:catch var="isNumber">
												   <c:set var="temp" value="${pair.first * 1}" />
												</c:catch>
												<c:if test="${isNumber != null}">
													<c:set var="isNumericList" value="false"/>
												</c:if>
											</c:if>
										</c:forEach>
										<c:if test="${isNumericList eq 'true'}">
											<c:choose>
												<c:when test="${formObjectForm.formField.referencedField eq otherObj.name}">
													<option value="<c:out value="${otherObj.name}"/>" selected="selected"><c:out value="${otherObj.name}"/> - <c:out value="${fn:substring(otherObj.label, 0, 30)}"/></option>
												</c:when>
												<c:otherwise>
													<option value="<c:out value="${otherObj.name}"/>"><c:out value="${otherObj.name}"/> - <c:out value="${fn:substring(otherObj.label, 0, 30)}"/></option>
												</c:otherwise>
											</c:choose>
										</c:if>
									</c:if>
								</c:when>
								<c:otherwise>
									<c:choose>
										<c:when test="${formObjectForm.formField.referencedField eq otherObj.name}">
											<smvc:option value="${otherObj.name}" selected="selected"><c:out value="${otherObj.name}"/> - <c:out value="${fn:substring(otherObj.label, 0, 30)}"/></smvc:option >
										</c:when>
										<c:otherwise>
											<smvc:option value="${otherObj.name}"><c:out value="${otherObj.name}"/> - <c:out value="${fn:substring(otherObj.label, 0, 30)}"/></smvc:option>
										</c:otherwise>
									</c:choose>
								</c:otherwise>
							</c:choose>
						</c:if>
					</c:if>
				</c:forEach>
			</smvc:select>
		</td>
	</tr>
	<tr>
		<td class="label">When other field value is within the range:</td>
		<td class="input">

			<table>
				<tr>
					<td align="center">Low value<br/><smvc:input size="15" title="Enter the low value for this range" path="bandingDataNew.lowerBand"/></td>
					<td align="center">High value<br/><smvc:input size="15" title="Enter the high value for this range" path="bandingDataNew.higherBand"/></td>
					<td align="center">Display this Message:<br/><smvc:input size="50" maxlength="200"  title="Enter a message to display" path="bandingDataNew.message"/></td>
					<td>In this Colour:<br/><smvc:select id="textColorId" onchange="setStyle('textColor');" path="bandingDataNew.assignColor">
						<smvc:option  value="#000000"	style="background-color: Black; color: #FFFFFF;">Black</smvc:option >
						<smvc:option  value="#808080" style="background-color: Gray;">Gray</smvc:option >
						<smvc:option  value="#A9A9A9" style="background-color: DarkGray;">DarkGray</smvc:option >
						<smvc:option  value="#D3D3D3" style="background-color: LightGrey;">LightGray</smvc:option >
						<smvc:option  value="#FFFFFF" style="background-color: White;">White</smvc:option >
						<smvc:option  value="#7FFFD4" style="background-color: Aquamarine;">Aquamarine</smvc:option >
						<smvc:option  value="#0000FF" style="background-color: Blue;">Blue</smvc:option >
						<smvc:option  value="#000080" style="background-color: Navy; color: #FFFFFF;">Navy</smvc:option >
						<smvc:option  value="#800080" style="background-color: Purple; color: #FFFFFF;">Purple</smvc:option >
						<smvc:option  value="#FF1493" style="background-color: DeepPink;">DeepPink</smvc:option >
						<smvc:option  value="#EE82EE" style="background-color: Violet;">Violet</smvc:option >
						<smvc:option  value="#FFC0CB" style="background-color: Pink;">Pink</smvc:option >
						<smvc:option  value="#006400" style="background-color: DarkGreen; color: #FFFFFF;">DarkGreen</smvc:option >
						<smvc:option  value="#008000" style="background-color: Green; color: #FFFFFF;">Green</smvc:option >
						<smvc:option  value="#9ACD32" style="background-color: YellowGreen;">YellowGreen</smvc:option >
						<smvc:option  value="#FFFF00" style="background-color: Yellow;">Yellow</smvc:option >
						<smvc:option  value="#FFA500" style="background-color: Orange;">Orange</smvc:option >
						<smvc:option  value="#FF0000" style="background-color: Red;">Red</smvc:option >
						<smvc:option  value="#A52A2A" style="background-color: Brown;">Brown</smvc:option >
						<smvc:option  value="#DEB887" style="background-color: BurlyWood;">BurlyWood</smvc:option >
						<smvc:option  value="#F5F5DC" style="background-color: Beige;">Beige</smvc:option >
					</smvc:select></td>
				</tr>
				<tr>
					<td colspan="3" ></td>
					<td align="right"><input type="submit" value="Add Band" onclick="return dispatch('addBanding')"/></td>
				</tr>
				<c:if test="${not empty formObject.bandingData }">
				<tr>
					<td align="center"><u>Low</u></td>
					<td align="center"><u>High</u></td>
					<td align="center"><u>Message</u></td>
					<td>Colour</td>
					<td></td>
					</tr>
					<c:forEach var="bandingData" items="${formObject.bandingData}" varStatus="index">
						<tr>
							<td><c:out value="${bandingData.lowerBand}"/></td>
							<td><c:out value="${bandingData.higherBand}"/></td>
							<td><c:out value="${bandingData.message}"/></td>
							<td>
								<c:if test="${not empty bandingData.assignColor}">
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '000000'}"><div style="background-color: Black; color: #FFFFFF;">Black</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '808080'}"><div style="background-color: Gray;">Gray</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'A9A9A9'}"><div style="background-color: DarkGray;">DarkGray</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'D3D3D3'}"><div style="background-color: LightGrey;">LightGray</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'FFFFFF'}"><div style="background-color: White;">White</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '7FFFD4'}"><div style="background-color: Aquamarine;">Aquamarine</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '0000FF'}"><div style="background-color: Blue;">Blue</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '000080'}"><div style="background-color: Navy; color: #FFFFFF;">Navy</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '800080'}"><div style="background-color: Purple; color: #FFFFFF;">Purple</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'FF1493'}"><div style="background-color: DeepPink;">DeepPink</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'EE82EE'}"><div style="background-color: Violet;">Violet</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'FFC0CB'}"><div style="background-color: Pink;">Pink</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '006400'}"><div style="background-color: DarkGreen; color: #FFFFFF;">DarkGreen</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '008000'}"><div style="background-color: Green; color: #FFFFFF;">Green</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq '9ACD32'}"><div style="background-color: YellowGreen;">YellowGreen</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'FFFF00'}"><div style="background-color: Yellow;">Yellow</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'FFA500'}"><div style="background-color: Orange;">Orange</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'FF0000'}"><div style="background-color: Red;">Red</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'A52A2A'}"><div style="background-color: Brown;">Brown</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'DEB887'}"><div style="background-color: BurlyWood;">BurlyWood</div></c:if>
									<c:if  test="${fn:substring(bandingData.assignColor, 1,fn:length(bandingData.assignColor)) eq 'F5F5DC'}"><div style="background-color: Beige;">Beige</div></c:if>
								</c:if>
							</td>
							<td>
								<img src="../images/delete.png" alt="Remove" title="Remove" border="0" style="cursor: pointer;" onclick="javascript:removeBanding('<c:out value="${index.count-1}"/>');"/>
								<smvc:hidden path="selectedBandingDataIndex" id="selectedBandingDataIndex"/>
							</td>
						</tr>
					</c:forEach>
				</c:if>			</table>
		</td>
	</tr>
<script type="text/javascript">
$("#showFields").click (function () {
	$("#fieldsList").toggle();
});
$("#showHelp").click (function () {
	$("#help").toggle();
});

</script>