<%@ include file="/includes.jsp" %>
<%@page import="com.ardeo.entities.autoforms.FormSection"%>

<script type="text/javascript">
function saveComments() {
	var comment  = document.getElementById('comments').value;
	var formName = document.getElementById("formName");
	var formValue=null;
	if(formName!=null){
		formValue = document.getElementById("formName").value;
	}
	setClinicians();
	var maxLen = 250;
	if(comment==null){
		alert("Comment cannot be blank");
		return false;
	}else{
	    var returnValue =trimAll(comment);
	    if(returnValue.length==0){
	    	alert("Comment cannot be blank");
			return false;
	    }
	}
	if(comment.length > maxLen){
		alert("Maximum 250 characters only.");
		return false;
	} else {
		document.getElementById("actionRequired").value = "savecomments";
		preSubmit();
		document.getElementById("consultationNote").submit();
	}
}
function send() {
	if(confirm('Please confirm that you want to send this message to the referrer')){
		if("true" == document.getElementById('roleSupportingStaff').value){
			chooseSeniors();
		}else{
			document.getElementById("actionRequired").value = "save";
			preSubmit();
			document.getElementById("consultationNote").submit();
		}
		
	}
}

// include content for fieldRenderer8.jsp.  Note that the content is JS but the file extension is .JSP
<%@ include file="/emdt/tiles/forms/userFunctionLibrary.jsp" %>

</script>

<tiles:importAttribute /><%--This imports all tiles attributes to page --%>

<c:if test="${empty parentPage}">
	<c:set var="parentPage" value=""/>
</c:if>
<table width="100%" >
	<tr>
		<c:forEach var="section" items="${pge.children }" varStatus="sectionIndex">
			<c:set var="sectionIndexCount" value="${sectionIndex.count }"/>
			<%
				com.ardeo.entities.autoforms.FormSection section=(com.ardeo.entities.autoforms.FormSection)pageContext.getAttribute("section");
				com.ardeo.entities.autoforms.FormPage pge=(com.ardeo.entities.autoforms.FormPage)pageContext.getAttribute("pge");
				Integer sectionIndexCount=(Integer)pageContext.getAttribute("sectionIndexCount");
			%>
			<td style="padding: 5px" valign="<%=section.getVAlign()%>" align="<%=section.getHAlign()%>">
				<%-- START SECTION --%>
				<tiles:insertTemplate template="standardSectionRenderer.jsp" flush="false">
					<tiles:putAttribute name="section" value="${section}"/>
					<tiles:putAttribute name="pageWritable" value="true"/>
					 <tiles:putAttribute name="parentPage" value="${parentPage}"/> 
					<tiles:putAttribute name="sectionIndex" value="${sectionIndex.count-1}" />
				</tiles:insertTemplate>
				<%-- END SECTION --%>
			</td>
			<%-- EITHER START A NEW ROW OR INSERT SPACE DEPENDING ON SECTION COUNT --%>
			<%
				if ((sectionIndexCount.intValue()  % pge.getSectionsPerRow()) == 0) {
			%>
     </tr>
</table>
<br />
<table width="100%">
	<tr>
		<%}%>
		</c:forEach>
	</tr>

</table>