<%@ include file="/includes.jsp"%>
<script src="../../../js/AJAXSupport.js" type="text/javascript"></script>
<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;
	}
	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 trimAll(sString){
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
} 
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();
		}
		
	}
}

</script>

<%-- Requirement #336(New Images don't get automatically fetched)--%>
<%@ include file="../amendedPatientMsgPopup.jsp"%>
<input type="hidden" id="onclickComplted" value="false">
<input type="hidden" id="consultationNoteFormId"
	name="consultationNoteFormId" value="<c:out value="${consultationNoteFormId}"/>"></input>
<tiles:importAttribute />	
<%--This imports all tiles attributes to page --%>
<%
com.ardeo.entities.autoforms.FormPage pge=(com.ardeo.entities.autoforms.FormPage)pageContext.getAttribute("pge");
%>
<div id="noDataFoundID" align="center"
	style="display: none; color: red; font-size: 14pt; float: left; height: 20px; width: 100%;">
<img src="../images/16x16/error.png" alt="Error" /></div>

<input type="hidden" name="primaryClinician" id="primaryClinician"
	value="<c:out value="${webapp.currentUser.username}"/>" /> <input type="hidden"
	name="roleSupportingStaff" id="roleSupportingStaff"
	value="${webapp.roleSupportingStaff}" /> <!--put the below  section here if not in test mode  --> 
	<c:if test="${(consultationNoteForm.view.note.id ne null) and (0 ne emdt.currentCareSpell.referralDetails.referralStatus) and (('PreTreatmentCTScan' eq consultationNoteForm.view.formName) or ('PreTreatmentMRIScan' eq consultationNoteForm.view.formName) or ('PreTreatmentPETCTScan' eq consultationNoteForm.view.formName) or ('PostChemoCTScan' eq formViconsultationNoteForm.view.formName) or ('PostChemoMRIScan' eq consultationNoteForm.view.formName) or ('OtherScan' eq consultationNoteForm.view.formName))}">
		<c:if test="${webapp.roleManagement}">
			<div style="float: right;"><a style="text-decoration: underline"
				href="../referrals/imgStatusUpdate.form?conNote=<c:out value="${consultationNoteForm.view.note.guid}"/>">Change
			image status</a></div>
		</c:if>
	</c:if>

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

</table>

<%@ include file="../chooseSeniorStaffLayout.jsp"%>
<%@ include file="../progressPopup.jsp"%>