<%@ taglib uri="/tags/struts-bean-el" prefix="bean-el" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html-el" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/tags/fw" prefix="fw" %>
<%@ taglib uri="/tags/esr-core" prefix="esrcore" %>

<c:set var="mmddyyyyText" scope="page"><bean-el:message key="label.mmddyyyy"/></c:set>

<SCRIPT>

function resetPowCaptivityDays(index)
{
    	var fieldName = "powCaptivityDays[" + index + "]";
 	document.getElementById(fieldName).value = "";
}
</SCRIPT>

<c:choose>
  <c:when test="${pageName == 'updatePOWRegistry'}">
    <tr>
	<td class="moduleLabel"><bean-el:message key="label.required.prefix" />&nbsp;<bean-el:message key="label.pow.indicator" />:</td>
	<td class="moduleValue">
		<c:forEach var="item" items="${yesNoList}">
		<c:set var="indicatorText"><bean-el:message key="label.required" />,&nbsp;<bean-el:message key="label.pow.indicator" />&nbsp;(<bean-el:message key="${item.label}" />)</c:set>
			<html-el:radio title="${indicatorText}" property="powIndicator" styleId="powIndicatorId_${item.value}" value="${item.value}" disabled="${readOnlyRegistry}"/>
			<fw:label property="powIndicator" forId="powIndicatorId_${item.value}"><bean-el:message key="${item.label}" />&nbsp;&nbsp;</fw:label>
		</c:forEach>
	</td>
    </tr>
  </c:when>
  <c:otherwise>
	<html-el:hidden property="powIndicator" value="y"/>
  </c:otherwise>
</c:choose>

<%@ include file="registryCommonFields.jsp" %>
<tr><td colspan="2">&nbsp;</td></tr>
<tr>
	<td class="moduleLabel"><fw:label property="dateDeath" forId="dateDeathId"><bean-el:message key="label.pow.dateDeath" />:</fw:label></td>
	<c:set var="dateDeathText"><bean-el:message key="label.pow.dateDeath" />&nbsp;<c:out value="${mmddyyyyText}"/></c:set>
	<td class="moduleValue"><html-el:text title="${dateDeathText}" property="dateDeath" styleClass="moduleEdit" styleId="dateDeathId" size="25" maxlength="19" readOnly="${readOnlyRegistry}"/>&nbsp;</td>
</tr>
<tr><td colspan="2">&nbsp;</td></tr>

<tr>
	<td class="moduleLabel" colspan="2">
	    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="moduleShellTableHead">
		<tr>
			<td class="moduleBrownBox"><img alt=""  src="../images/spacer.gif" width="28" height="23"/></td>
			<td nowrap width="100%">&nbsp;<bean-el:message key="label.pow.episodes" /></td>
			<c:if test="${pageName == 'updatePOWRegistry'  && readOnlyRegistry == false}">
			    <td nowrap>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				    <tr>
				    	<td width="100%"><img alt=""  src="../images/spacer.gif" width="1" height="1" /></td>
					<td><img alt=""  src="../images/buttonEndLeft.gif" width="12" height="21" /></td>
					<td class="buttonText"><html-el:submit property="methodName" styleClass="buttonText" style="width:120; vertical-align: top;"><bean-el:message key="button.addPOWEpisode" /></html-el:submit></td>
					<td><img alt=""  src="../images/buttonEndRight.gif" width="12" height="21" /></td>
					<td>&nbsp;</td>
				    </tr>
    				</table>
			    </td>
			</c:if>
		</tr>
	    </table>
	</td></tr>
</tr>
<c:set var="rowColor" value="light"/>
<c:forEach var="item" items="${registryPOWInfoForm.episodeIdList}" varStatus="status">
    <c:choose>
	<c:when test="${rowColor == 'light'}">
	    <c:set var="rowColor" value="dark"/>
	    <c:set var="rowLabelColor" value="darkLabel"/>
	    <c:set var="rowValueColor" value="darkValue"/>
	</c:when>
	<c:otherwise>
	    <c:set var="rowColor" value="light"/>
	    <c:set var="rowLabelColor" value="label"/>
	    <c:set var="rowValueColor" value="value"/>
	</c:otherwise>
    </c:choose>
    <c:set var="counter" value="${status.count - 1}" />
    <c:set var="episodeId" value="${item}" />
    <html-el:hidden property="episodeId[${counter}]" />
    <c:set var="hashCode" value="${registryPOWInfoForm.episodeHashCodeList[counter]}" />

    <tr><td class="<c:out value="${rowValueColor}" />" colspan="2"><img alt=""  src="../images/spacer.gif" width="28" height="5"/></td></tr>
    <tr>
    	<td class="<c:out value="${rowLabelColor}" />"><fw:label property="documentType[${counter}],documentType_${hashCode}" forId="documentType[${counter}]_id"><bean-el:message key="label.registry.documentType" />:</fw:label></td>
    	<td class="<c:out value="${rowValueColor}" />">
    	<c:set var="documentTypeText"><bean-el:message key="label.registry.documentType" />&nbsp;<c:out value="${counter+1}" /></c:set>
    	    <html-el:select title="${documentTypeText}" styleClass="moduleEdit" styleId="documentType[${counter}]_id" property="documentType[${counter}]" disabled="${readOnlyRegistry}">
    		<html-el:option styleClass="moduleEdit" value=""><bean-el:message key="label.select" /></html-el:option>
    		<esrcore:options styleClass="moduleEdit" collection="gov.va.med.esr.common.model.lookup.POWDocumentType" property="code" labelProperty="description"/>
    	    </html-el:select>
    	</td>
    </tr>
    <tr>
	<td class="<c:out value="${rowLabelColor}" />"><fw:label required="true" property="dataSource[${counter}],dataSource_${hashCode}" forId="dataSource[${counter}]_id"><bean-el:message key="label.pow.Source" />:</fw:label></td>
	<td class="<c:out value="${rowValueColor}" />">
	<c:set var="sourceText"><bean-el:message key="label.required" />,&nbsp;<bean-el:message key="label.pow.Source" />&nbsp;<c:out value="${counter+1}" /></c:set>
	    <html-el:select title="${sourceText}" styleClass="moduleEdit" styleId="dataSource[${counter}]_id" property="dataSource[${counter}]" disabled="${readOnlyRegistry}">
		<html-el:option styleClass="moduleEdit" value=""><bean-el:message key="label.select" /></html-el:option>
		<esrcore:options styleClass="moduleEdit" collection="gov.va.med.esr.common.model.lookup.POWDataSource" property="code" labelProperty="description"/>
	    </html-el:select>
	</td>
    </tr>
    <tr>
    	<td class="<c:out value="${rowLabelColor}" />"><fw:label required="true" property="powCaptureDate[${counter}],powCaptureDate_${hashCode}" forId="powCaptureDate[${counter}]_id"><bean-el:message key="label.pow.captureDate" />:</fw:label></td>
    	<c:set var="captureDateText"><bean-el:message key="label.required" />,&nbsp;<bean-el:message key="label.pow.captureDate" />&nbsp;<c:out value="${counter+1}" />&nbsp;<c:out value="${mmddyyyyText}" /></c:set>
    	<td class="<c:out value="${rowValueColor}" />"><html-el:text title="${captureDateText}" property="powCaptureDate[${counter}]" styleClass="moduleEdit" styleId="powCaptureDate[${counter}]_id" size="10" maxlength="10" onkeyup="resetPowCaptivityDays(${counter});" disabled="${readOnlyRegistry}" onchange="javascript:powCaptivityDays(${counter})" />&nbsp;<bean-el:message key="label.mmddyyyy" /></td>
    </tr>
    <tr>
    	<td class="<c:out value="${rowLabelColor}" />"><fw:label required="true" property="powReleaseDate[${counter}],powReleaseDate_${hashCode}" forId="powReleaseDate[${counter}]_id"><bean-el:message key="label.pow.releaseDate" />:</fw:label></td>
    	<c:set var="releaseDateText"><bean-el:message key="label.required" />,&nbsp;<bean-el:message key="label.pow.releaseDate" />&nbsp;<c:out value="${counter+1}" />&nbsp;<c:out value="${mmddyyyyText}" /></c:set>
    	<td class="<c:out value="${rowValueColor}" />"><html-el:text title="${releaseDateText}" property="powReleaseDate[${counter}]" styleClass="moduleEdit" styleId="powReleaseDate[${counter}]_id" size="10" maxlength="10" onkeyup="resetPowCaptivityDays(${counter});" disabled="${readOnlyRegistry}" onchange="javascript:powCaptivityDays(${counter})" />&nbsp;<bean-el:message key="label.mmddyyyy" /></td>
    </tr>
    <tr>
	<td class="<c:out value="${rowLabelColor}" />"><fw:label property="powCaptivityDays[${counter}]" forId="powCaptivityDays[${counter}]_id"> <bean-el:message key="label.pow.daysInCaptivity" />: </fw:label></td>
	<c:set var="daysInCaptivityText"><bean-el:message key="label.pow.daysInCaptivity" />&nbsp;<c:out value="${counter+1}" /></c:set>
	<td class="<c:out value="${rowValueColor}" />"><html-el:text title="${daysInCaptivityText}"  styleId="powCaptivityDays[${counter}]_id" readonly="true" property="powCaptivityDays[${counter}]" styleClass="moduleEdit" size="10" maxlength="10" disabled="${readOnlyRegistry}"/></td>
    </tr>
    <tr>
    	<td class="<c:out value="${rowLabelColor}" />"><fw:label required="true" property="confinementLocation[${counter}],confinementLocation_${hashCode}" forId="confinementLocation[${counter}]_id"><bean-el:message key="label.pow.confinementLocation" />:</fw:label></td>
    	<td class="<c:out value="${rowValueColor}" />">
    	<c:set var="confinementLocationText"><bean-el:message key="label.required" />,&nbsp;<bean-el:message key="label.pow.confinementLocation" />&nbsp;<c:out value="${counter+1}" /></c:set>
		<html-el:select title="${confinementLocationText}" styleClass="moduleEdit" styleId="confinementLocation[${counter}]_id" property="confinementLocation[${counter}]" disabled="${readOnlyRegistry}">
			<html-el:option styleClass="moduleEdit" value=""><bean-el:message key="label.select" /></html-el:option>
			<esrcore:options styleClass="moduleEdit" collection="gov.va.med.esr.common.model.lookup.PrisonerOfWarLocation" property="code" labelProperty="description"/>
		</html-el:select>
    	</td>
    </tr>
    <tr>
    	<td class="<c:out value="${rowLabelColor}" />"><fw:label property="campLocation[${counter}]" forId="campLocation[${counter}]_id"> <bean-el:message key="label.pow.campLocation" />:</fw:label></td>
    	<td class="<c:out value="${rowValueColor}" />">
    	<c:set var="campLocationText"><bean-el:message key="label.pow.campLocation" />&nbsp;<c:out value="${counter+1}" /></c:set>
    		<html-el:select title="${campLocationText}" styleClass="moduleEdit" property="campLocation[${counter}]" styleId="campLocation[${counter}]_id" disabled="${readOnlyRegistry}">
    			<html-el:option styleClass="moduleEdit" value=""><bean-el:message key="label.select" /></html-el:option>
    			<esrcore:options styleClass="moduleEdit" collection="gov.va.med.esr.common.model.lookup.POWCampLocation" property="code" labelProperty="description"/>
    		</html-el:select>
    	</td>
   </tr>

   <c:choose>
       <c:when test="${empty episodeId}">
       	<tr><td class="<c:out value="${rowValueColor}" />" colspan="2"><html-el:hidden property="powEpisodeEnteredDate[${counter}]"/></td></tr>
       	<tr><td class="<c:out value="${rowValueColor}" />" colspan="2"><html-el:hidden property="powEpisodeEnteredBy[${counter}]"/></td></tr>
       </c:when>
       <c:otherwise>
   	<tr>
   		<td class="<c:out value="${rowLabelColor}" />"><bean-el:message key="label.pow.dateEntered" />:</td>  
   		<c:set var="powDateEnteredText"><bean-el:message key="label.pow.dateEntered" /></c:set> 		
   		<td title="<c:out value="${powDateEnteredText} ${counter+1}"/>" class="<c:out value="${rowValueColor}" />"><html-el:hidden property="powEpisodeEnteredDate[${counter}]"/><c:out value="${registryPOWInfoForm.powEpisodeEnteredDateList[counter]}"/></td>
   	</tr>
   	<tr>
   		<td class="<c:out value="${rowLabelColor}" />"><bean-el:message key="label.pow.enteredBy" />:</td>
   		<c:set var="enteredByText"><bean-el:message key="label.pow.enteredBy" /></c:set>
   		<td title="<c:out value="${enteredByText} ${counter+1}"/>"  class="<c:out value="${rowValueColor}" />">
   			<html-el:hidden property="powEpisodeEnteredBy[${counter}]"/>
   			<c:set var="powEpisodeEnteredBy" value="${registryPOWInfoForm.powEpisodeEnteredByList[counter]}"/>
			<esrcore:displayLookupValue lookupType="gov.va.med.esr.common.model.security.ESRUserPrincipalImpl" name="powEpisodeEnteredBy" />
   		</td>
   	</tr>
       </c:otherwise>
  </c:choose>
  <tr><td class="<c:out value="${rowValueColor}" />" colspan="2"><img alt=""  src="../images/spacer.gif" width="28" height="5"/></td></tr>

</c:forEach>

<tr><td class="moduleValue" colspan="2">&nbsp;</td></tr>
<tr>
	<td class="moduleLabel"><fw:label property="icn" forId="icnId"><bean-el:message key="label.pow.icn" />:</fw:label></td>
	<c:set var="icnText"><bean-el:message key="label.pow.icn" /></c:set>
	<td class="moduleValue"><html-el:text title="${icnText}" property="icn" styleClass="moduleEdit" styleId="icnId" size="30" maxlength="30" disabled="${readOnlyRegistry}"/></td>
</tr>

<c:choose>
    <c:when test="${empty registryPOWInfoForm.registryId}">
	<tr>
		<td class="moduleValue" colspan="2"><html-el:hidden property="dateEntered"/></td>
	</tr>
    </c:when>
    <c:otherwise>
    	<tr>
    		<td class="moduleLabel"><bean-el:message key="label.dateEntered" />:</td>    
    		<c:set var="dateEnteredText"><bean-el:message key="label.dateEntered" /></c:set> 		
    		<td title="<c:out value="${dateEnteredText}"/>" class="moduleValue"><html-el:hidden property="dateEntered"/><c:out value="${registryPOWInfoForm.dateEntered}"/></td>
	</tr>
    </c:otherwise>
</c:choose>


<c:if test="${pageName == 'updatePOWRegistry'}">
    <tr><td class="moduleValue" colspan="2">&nbsp;</td></tr>
    <tr>
	<td class="moduleLabel"><bean-el:message key="label.updatedBy" />:</td>
	<c:set var="updatedByText"><bean-el:message key="label.updatedBy" /></c:set>
	<td title="<c:out value="${updatedByText}"/>" class="moduleValue"><html-el:hidden property="updatedBy"/>	
		<esrcore:displayLookupValue lookupType="gov.va.med.esr.common.model.security.ESRUserPrincipalImpl" name="registryPOWInfoForm" property="updatedBy" />
	</td>
    </tr>
    <tr>
	<td class="moduleLabel"><bean-el:message key="label.updateDateTime" />:</td>
	<c:set var="updateDateTimeText"><bean-el:message key="label.updateDateTime" /></c:set>
	<td title="<c:out value="${updateDateTimeText}"/>" class="moduleValue"><html-el:hidden property="updatedDate"/><c:out value="${registryPOWInfoForm.updatedDate}"/></td>
    </tr>
</c:if>
