<%@ include file="/includes.jsp"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<link rel="stylesheet" href="../tables.css" type="text/css" />
<%@page import="java.util.Arrays"%>
<%@page import="java.util.ArrayList"%>
<link rel="stylesheet" href="../css/tables.css" type="text/css" />

<script src="../js/ReferralsDefinition.js" type="text/javascript"></script>
<smvc:form id="referralsDefinitionForm">
	<input type="hidden" name="redirectParams" value="<c:out value="${requestScope['javax.servlet.forward.query_string']}" />" />
	<br/>
	<br/>
	<c:choose>
		<c:when
			test="${requestScope.successMsg != null || requestScope.errorMsg != null}">
			<c:if test="${requestScope.successMsg != null}">
				<div class="message"><img
					src="../images/16x16/information.png" alt="i" />
				<c:out value="${requestScope.successMsg}"/></div>
			</c:if>
			<c:if test="${requestScope.errorMsg != null}">
				<div class="error"><img
					src="../images/16x16/error.png" alt="e" /><c:out value="${requestScope.errorMsg}"/></div>
				<br />
			</c:if>
		</c:when>
		<c:otherwise>
		</c:otherwise>
	</c:choose>
	<smvc:errors />

	<fieldset style="width: 50%" class="nobg"><input
		type="hidden" name="task" id="task" /> <input type="hidden"
		name="referralsDefinitionId" id="referralsDefinitionId"
		value="${referralsDefinitionId}" /> <input type="hidden"
		name="groupFormId" id="groupFormId" /> <legend>Form Groups</legend>
	<fieldset class="buttonFieldset">
	<table width="100%">
		<tr>
			<td colspan="9">&#160;</td>
		</tr>
		<tr>
			<td>
			<table border="1" bordercolor="#F8F8FF" cellspacing="0"
				cellpadding="4" width="100%">
				<tr>
					<th>Name</th>
					<th>Delete</th>
					<th>System</th>
				</tr>
				<c:forEach var="groupForm" items="${groupForms}">
					<tr>
						<td><c:out value="${groupForm.groupName}"/></td>
						<td><c:if test="${groupForm.isDisable eq false }">
							<a onclick="deleteGroup(10,${groupForm.formGroupId});return false;"
								title="Delete Group"
								onmouseover="this.style.cursor = cursorPointer;"
							   disabled="<c:out value="${groupForm.isDisable}"/>"
							> <img
							src="../images/delete.png" border="0" alt="Delete">
							</a>
							</c:if>
							</td>
						<td><c:choose>
							<c:when test="${groupForm.isDisable eq true}">
									Yes
								</c:when>
							<c:otherwise>
									No
								</c:otherwise>
						</c:choose></td>
					</tr>
				</c:forEach>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="9">&#160;</td>
		</tr>
		<tr>
			<td><input type="button" value="Add Group"
				onclick="if(document.getElementById('newGroup').value=='') alert('Group Name can not be empty'); else createNewReferralsDefinitionForm(9);"></input>
			<input type="text" name="newGroup" id="newGroup" /></td>
		</tr>
	</table>
	</fieldset>
	<fieldset class="buttonFieldset"><input type="button"
		value="List Referral Pathways" onclick="sentReq(6);" />
			<c:choose>
				<c:when test="${referralsDefinitionId!=null and referralsDefinitionId!=''}">
					<input type="button" value="Back To Edit Referral Pathway"
						onclick="processEditDelete(3,'<c:out value="${referralsDefinitionId}"/>');return false;" />
				</c:when>
				<c:otherwise>
					<input type="button" value="Back To New Referral Pathways"
						onclick="createNewReferralsDefinitionForm(1);" />
				</c:otherwise>
		   </c:choose>
	</fieldset>
	<fieldset class="buttonFieldset">
	<div style="text-align: left;"><img src="../images/16x16/help.png" style="margin: 5px;"/> This screen lets you make a button which can contain a group of forms.<br/>
	Each 'Form Group' represents a button.  The 'Top Level' group is the top row of buttons.<br/>
	 For example, the Images and Reports 'form group' shows as one button in the Referral menu and when the user clicks it, they see the forms within that form group.</div>
	 </fieldset>
	</fieldset>
</smvc:form>