<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html>
<script type="text/javascript">
function saveDeliveryNode(){
	jQuery.ajax({
	   type: "POST",
	   url: "../admin/iepSetupDeliveryNode.form",
	   data:"deliveryNode="+document.getElementById('deliveryNodeID').value,
       success: function(msg){
        if(msg.error){
            var div = document.getElementById('errorMsgId');
		//	div.innerHTML = div.innerHTML + msg.error;
	        div.style.display="block";
        }
        if(msg.successMsg){
            var div =document.getElementById('successMsgId');
		//	div.innerHTML = div.innerHTML + msg.successMsg;
	        div.style.display="block";
        }
	  } 
	 });
	}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../webapp.css" type="text/css" />
</head>
<sec:authorize access="hasRole('ADMIN')">
<body style="margin: 0px">
<br /><br /><br /><br />
<div class="error" id="errorMsgId" style='display:none;'><img src="../images/16x16/error.png" alt="!"
	border="0" />&nbsp;&nbsp;could not be saved.</div>
<div class="message" id="successMsgId" style='display:none;'><img src="../images/16x16/information.png" alt="!"
	border="0" />&nbsp;&nbsp;saved successfully.</div>
<table cellpadding="0" cellspacing="0" width="70%" class="HTres">
	<tr >
		<td valign="top" class="moduleContentArea1">
		<form name="selectIEPDeliveryNodeForm"
			action="../admin/iepSetup.form" method="post">
		<div class="containerMedium">
		<div class="rowSpacer">&nbsp;</div>
		<div class="rowDiv">
		<fieldset style="width: 100%;" class="nobg"><legend>
		IEP Delivery Node for <c:out value="${centralHubHospital.hospitalName}"/>  </legend>
		<fieldset><c:if
			test="${deliveryNodeList!=null and fn:length(deliveryNodeList)>0}">
			<table width="100%">
				<tr>
					<td><br />
					</td>
				</tr>
				<tr>
					<td align="right">Select A Delivery Node:</td>
					<td align="left"><select id="deliveryNodeID"
						name="deliveryNode" >
						<c:forEach var="deliveryNode" items="${deliveryNodeList}">
							<c:choose>
								<c:when test="${iepDeliveryNode ne null and iepDeliveryNode eq deliveryNode.deliveryNodeName}">
									<option value="<c:out value="${deliveryNode.deliveryNodeName}" />" selected="selected" ><c:out value="${deliveryNode.deliveryNodeName}"/></option>
								</c:when>
								<c:otherwise>
									<option value="<c:out value="${deliveryNode.deliveryNodeName}" />" ><c:out value="${deliveryNode.deliveryNodeName}"/></option>
								</c:otherwise>
							</c:choose>
							
						</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td><br />
					<br />
					</td>
				</tr>
				<tr>
					<td></td>
					<td><input type="button" value="Save.." onclick="saveDeliveryNode();"></input></td>
				</tr>
				<tr>
					<td><br />
					<br />
					</td>
				</tr>
			</table>
		</c:if>
		<c:if test="${deliveryNodeList == null or fn:length(deliveryNodeList) == 0}">
			<span class="alert">No delivery nodes were found.  This may be due to an incorrect organisation code.</span>
		</c:if>
			<c:if test="${errorMsg ne null}">
				<span class="error">Error: ${errorMsg}</span>
			</c:if>
		</fieldset>
		</fieldset>
		</div>
		</div>
		</form>
		</td>
	</tr>
</table>
</body></sec:authorize>
</html>
