<%@ include file="/includes.jsp"%>

<script language="javascript">
function textCounter(field, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0,3000);
else
return true;
}
function closeThread(){
var threadId = document.patientForumDiscussionForm.threadId.value;
var value = confirm("Are you sure you want to close this thread?  \n\nThis will prevent further responses being posted.");
if(value == true){
//document.patientForumDiscussionForm.submitName.value='closeThread';
//alert("abc :"+document.patientForumDiscussionForm.submitName.value);
document.location="patientDiscussion.do?closeThreadId="+threadId+"&close="+1+"&submitName="+'closeThread';
}
}
function back(){
document.location="patientDiscussionLink.do"
}
</script>

<s:form action="/meetings/patientDiscussion" styleId="patientDiscussion">

	<table border="0" width="95%" height="500">
		<tr>
			<td valign="top">
			<fieldset>
			<table cellpadding="6" cellspacing="0" border="0" width="100%" height="100" align="center">
				<tr>
					<td class="menuItem" colspan="6"><span style="font-weight: bold; font-size: 12pt;">Q and A Forum - view thread<br />
					</span></td>
				</tr>
				<tr>
					<td><span style="font-weight: bold; font-size: 10pt;">Discussion Topic</span></td>
					<td colspan="5"><c:out value="${patientForumDiscussionForm.discussionTopic}"/></td>


				</tr>

				<tr>
					<td><span style="font-weight: bold; font-size: 10pt;">Posted To</span></td>
					<td><c:out value="${patientForumDiscussionForm.postedTo}"/></td>

					<td><span style="font-weight: bold; font-size: 10pt;">Posted By</span></td>
					<td><c:out value="${patientForumDiscussionForm.postedBy}"/></td>

					<td>&#160;</td>
					<td>&#160;</td>
				</tr>

				<tr>
					<td><span style="font-weight: bold; font-size: 10pt;">Start Date</span></td>
					<td><c:out value="${patientForumDiscussionForm.startDate}"/></td>

					<td><span style="font-weight: bold; font-size: 10pt;">End Date</span></td>
					<td><c:out value="${patientForumDiscussionForm.endDate}"/></td>

					<td><span style="font-weight: bold; font-size: 10pt;">DeadLine ?</span></td>
					<td><c:out value="${patientForumDiscussionForm.deadLine}"/></td>
				</tr>
			</table>
			</fieldset>
			<c:if test="${patientDiscussion ne null}">
				<table class="table" cellpadding="6" cellspacing="0" border="0" width="100%" align="center">
					<tr>
						<td class="tableTitleBar">Response/History</td>
					</tr>
				</table>
				<table class="table" cellpadding="6" cellspacing="0" border="1" width="100%" align="center">
					<tr class="tableHeader" >
						<th class="tableColHeader" width="10%">Date</th>
						<th class="tableColHeader" width="10%">Who</th>
						<th class="tableColHeader" width="80%">Comment</th>
					</tr>
					<c:forEach var="oneObj" items="${patientForumDiscussionForm.dissHistory }">
						<tr class="oddRow">
							<td class="tableCell" width="10%"><c:out value="${oneObj.commentDate}"/></td>
							<td class="tableCell" width="10%"><c:out value="${oneObj.username}"/></td>
							<td class="tableCell" width="80%"><c:out value="${oneObj.comments}"/></td>
						</tr>
					</c:forEach>
				</table>
				<br/>
				
			</c:if> 
			<c:if test="${closed eq null}">
				<table class="menu" cellpadding="6" cellspacing="0" border="0" width="100%" height="100" align="center">
					<tr>
						<td><span style="font-weight: bold; font-size: 10pt;">Comments</span></td>
					</tr>
					<tr>
						<td align="center"><html:textarea property="comments" rows="7" cols="80" value="Enter your text" onblur="textCounter(this.form.comments,4000);" /></td>
					</tr>
					<tr>
						<td align="right" valign="top"><html:button property="button" value=" Back " onclick="back();" /> 
						<html:submit property="submit" value="Post Reply" onclick="this.form.submitName.value='updateThread'" /> 
						<html:hidden property="threadId" /> 
						<html:hidden value="update" property="hidden" />
						<html:hidden property="submitName" /></td>
					</tr>
				</table>
			</c:if> 
			<c:if test="${closed ne null}">
				<table cellpadding="4" cellspacing="0" border="0" width="100%" height="10" align="center">
					<tr>
						<td>&#160;</td>
						<td align="center" valign="bottom"><html:button property="button" value=" Back " onclick="back();" />
						<td align="right" valign="top"><html:hidden property="threadId" />
						<td align="right" valign="top"><html:hidden value="update" property="hidden" />
					</tr>
				</table>
			</c:if>
			</td>
		</tr>
		<c:if test="${closed eq null}">
			<tr>
				<td><a href="javascript:closeThread();"><img src="images/close-thread.PNG" /><font color="#6D7B8D">Close Thread</font></a></td>
			</tr>
		</c:if>
		<c:if test="${closed ne null}">
			<tr>
				<td><img src="images/close-thread.PNG" /><font color="#6D7B8D">This thread is closed.</font></td>
			</tr>
		</c:if>
	</table>

</s:form>

