<%@ page import="gov.va.med.esr.ui.util.SessionManager"%>
<%@ page import="gov.va.med.esr.ui.financials.action.ThresholdAction"%>
<%@ taglib uri="/tags/struts-bean-el" prefix="bean-el" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ 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/esr-core" prefix="esrcore" %>
<%@ taglib uri="/tags/fw" prefix="fw" %>

<script>


function setZipCode(thisForm, option, block)
{
  if (option.value != null)
  {
    thisForm.zipCode.value = option.value;
    block.style.display = "none";
  }
}

function displayBlock(block)
{
  block.style.display = "none";
}

</script>

<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
<html-el:form action="/thresholds" method="post">
  <%@ include file="/admin/csrfgentoken.jsp" %>
  <tr>
    <td width="100%">

      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell" role="presentation">
        <tr>
          <td width="100%">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
              <tr>
                <td colspan="2">
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead" role="presentation">
                    <tr>
			  <td class="moduleBlueBox"><img alt=""  src="../images/spacer.gif" width="28" height="23"/></td>
			  <td nowrap class="moduleHeadline">Geographical Region and Income Year</td>
			  <td width="100%"><img alt=""  src="../images/spacer.gif"/> 
                    </tr>
                  </table>
                </td>
              </tr>

              <tr>
                <td width="45%" class="moduleLabel"><fw:label property="incomeYear" forId="idIncomeYear">Income Year:</fw:label></td>
                <td  width="55%" class="moduleValue">
                  <html-el:select title="Income year" styleClass="moduleEdit" property="incomeYear" styleId="idIncomeYear">
                  <html-el:option value=""><bean-el:message key="label.select" /></html-el:option>
                    <esrcore:options collection="<%= ThresholdAction.THRESHOLD_INCOME_YEAR_LIST_SESSION_KEY %>" property="value" labelProperty="label"/>
                  </html-el:select>
                </td>
              </tr>

              <tr>
                <td class="moduleLabel"><fw:label property="zipCode" forId="idZipCode">Zip Code:</fw:label></td>
                <td class="moduleValue"><html-el:text title="Required, Zip Code, or City or City/State can be used to look up Zip Code" styleClass="moduleEdit" property="zipCode" styleId="idZipCode" size="15" maxlength="15"/></td>
              </tr>

              <tr>
                <td class="moduleLabel">&nbsp;</td>
                <td class="moduleValue">Or</td>
              </tr>

              <tr>
                <td class="moduleLabel"><fw:label property="state" forId="idState">State:</fw:label></td>
                <td class="moduleValue">
                  <html-el:select title="State" styleClass="darkValue" property="state" styleId="idState">
                  <html-el:option value=""><bean-el:message key="label.select" /></html-el:option>
                    <esrcore:options collection="gov.va.med.esr.ui.common.beans.USState" property="code" labelProperty="name"/>
                  </html-el:select>
                </td>
              </tr>

              <tr>
                <td class="moduleLabel"><fw:label property="city" forId="idCity">City:</fw:label></td>
                <td class="moduleValue"><html-el:text title="City" styleClass="moduleEdit" property="city" styleId="idCity" size="20" maxlength="20"/></td>
              </tr>
            </table>

            <c:if test="${ZipCodeList != null}">
            <%-- pssn Expand/Collapse Section --%>
            <div id="optionBlock">
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
		 <tr>
               		<td width="45%" class="moduleLabel">Select Zip Code:</td>
               		<td width="55%" class="moduleValue">
			    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
			      <tr>
			        <td width="560" class="moduleValue"><p>
                      		    <c:forEach var="zip" items="${ZipCodeList}">
                        		<html-el:radio property="FIPSCode" value="${zip.code}" styleId="zipCode_${zip.code}" onClick="setZipCode(this.form, this, optionBlock);" />
                        			<fw:label property="FIPSCode" forId="zipCode_${zip.code}"><c:out value="${zip.code}" />&nbsp;&nbsp;</fw:label>
				    </c:forEach>
				</td>
				<td>&nbsp;</td>
			      </tr>
			    </table>
			</td>
		</tr>
		</table>
            </div>
            </c:if>

            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
              <tr>
                <td class="moduleValue">
                  <table width="100%" border="0" align="center" cellspacing="0" cellpadding="0" role="presentation">
                    <tr>
                      <td width="45%"><img alt=""  src="../images/spacer.gif"/></td>
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:50; vertical-align: top;" styleClass="buttonText"><bean:message key="button.search"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                      <td width="1%"><img alt=""  src="../images/spacer.gif"/></td>
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:50; vertical-align: top;" styleClass="buttonText"><bean:message key="button.clear"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                      <td width="1%"><img alt=""  src="../images/spacer.gif"/></td>
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:50; vertical-align: top;" styleClass="buttonText"><bean:message key="button.cancel"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                      <td width="45%"><img alt=""  src="../images/spacer.gif"/></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>

          </td>
        </tr>
      </table>

      <c:if test="${thresholdForm.gmtThreshold != null}">
      <br>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell">
        <tr>
          <td width="100%">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody">
              <tr>
                <td colspan="6">
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableHead">
                    <tr>
			  <td class="moduleBlueBox"><img alt=""  src="../images/spacer.gif" width="28" height="23"/></td>
			  <td nowrap class="moduleHeadline">Thresholds</td>
			  <td width="100%"><img alt=""  src="../images/spacer.gif"/> 
                    </tr>
                  </table>
                </td>
              </tr>
              <c:set var="currentYear" value="${thresholdForm.incomeYear + 1}" />
              <tr valign="top">
                <td width="134" class="darkLabel">&nbsp;</td>
                <td colspan="3" class="darkLabel"><p align="center">Thresholds
                  in place for tests completed<br>
                  01/01/<c:out value="${currentYear}"/> - 12/31/<c:out value="${currentYear}"/><br>
                  (Income Year <c:out value="${thresholdForm.incomeYear}"/>)</p></th>
                <th scope = "col" colspan="2" class="darkLabel"><div align="center">Effective
                  Dates<br>
                  01/01/<c:out value="${currentYear}"/> - 12/31/<c:out value="${currentYear}"/></div></td>
              </tr>

              <tr valign="top">
                <th scope = "col" class="label"><div align="left"></div></th>
                <th scope = "col" width="129" class="label" align="center"><div align="center">Means Test</div></th>
                <th scope = "col" width="130" class="label" align="center"><div align="center">GMT</div></th>
                <th scope = "col" width="127" class="label" align="center"><div align="center">Pension (RX)</div></th>
                <th scope = "col" width="131" class="label" align="center"><div align="center">Medical Deductible</div></th>
                <th scope = "col" width="149" class="label" align="center"><div align="center">Aid &amp; Attendance</div></th>
              </tr>

              <c:set var="rowColor" value="value" />
              <c:set var="labelColor" value="label" />

              <c:forEach var="threshold" items="${thresholdForm.GMTThreshold}" varStatus="status">
              	<c:set var="counter" value="${status.count-1}" />
              	<c:if test="${counter < 8}">

		      <c:choose>
		      <c:when test="${rowColor == 'value'}">
			<c:set var="rowColor" value="darkValue" />
			<c:set var="labelColor" value="darkLabel" />
		      </c:when>
		      <c:otherwise>
			<c:set var="rowColor" value="value" />
			<c:set var="labelColor" value="label" />
		      </c:otherwise>
		      </c:choose>

		      <tr valign="top">
			<th scope = "col" class="<c:out value="${labelColor}"/>" align="left"><div align="left"><c:out value="${counter}" /> Dependents:</div></th>
			<td class="<c:out value="${rowColor}"/>" align="center">
			  <c:choose>
			    <c:when test="${thresholdForm.MTThreshold[counter] != null}"> 
				<div align="center">$<c:out value="${thresholdForm.MTThreshold[counter]}" /></div>
			    </c:when>
			    <c:otherwise><div align="center">Not available</div></c:otherwise>
		      	  </c:choose>
			<td class="<c:out value="${rowColor}"/>" align="center">
			  <c:choose>
			    <c:when test="${thresholdForm.GMTThreshold[counter] != null}"> 
				<div align="center">$<c:out value="${thresholdForm.GMTThreshold[counter]}" /></div>
			    </c:when>
			    <c:otherwise><div align="center">Not available</div></c:otherwise>
		      	  </c:choose>
			</td>
			<td class="<c:out value="${rowColor}"/>" align="center">
			  <c:choose>
			    <c:when test="${thresholdForm.pensionThreshold[counter] != null}"> 
				<div align="center">$<c:out value="${thresholdForm.pensionThreshold[counter]}" /></div>
			    </c:when>
			    <c:otherwise><div align="center">Not available</div></c:otherwise>
		      	  </c:choose>
			</td>
			<td class="<c:out value="${rowColor}"/>" align="center">
			  <c:choose>
			    <c:when test="${thresholdForm.medicalDeductible[counter] != null}"> 
				<div align="center">$<c:out value="${thresholdForm.medicalDeductible[counter]}" /></div>
			    </c:when>
			    <c:otherwise><div align="center">Not available</div></c:otherwise>
		      	  </c:choose>
			</td>
			<td class="<c:out value="${rowColor}"/>" align="center"><div align="center">Not available</div></td>
		      </tr>

              	</c:if>
              </c:forEach>

              <tr valign="top">
                <td class="darkLabel" colspan="8">&nbsp;</td>
              </tr>
            

            <c:if test="${thresholdForm.additionalDependent != null}">
              <tr valign="top">
                <th scope = "col" class="darkLabel"><div align="left"><c:out value="${thresholdForm.additionalDependent + 7}"/> Dependents:</div></th>
                <td class="darkValue">
                  <c:choose>
		    <c:when test="${thresholdForm.addDepMTThreshold != null}"> 
			<div align="center">$<c:out value="${thresholdForm.addDepMTThreshold}" /></div>
		    </c:when>
		    <c:otherwise><div align="center">Not available</div></c:otherwise>
		  </c:choose>
		</td>
                <td class="darkValue">
                  <c:choose>
		    <c:when test="${thresholdForm.addDepGMTThreshold != null}"> 
			<div align="center">$<c:out value="${thresholdForm.addDepGMTThreshold}" /></div>
		    </c:when>
		    <c:otherwise><div align="center">Not available</div></c:otherwise>
		  </c:choose>
                </td>
                <td class="darkValue">
                  <c:choose>
		    <c:when test="${thresholdForm.addDepPensionThreshold != null}"> 
			<div align="center">$<c:out value="${thresholdForm.addDepPensionThreshold}" /></div>
		    </c:when>
		    <c:otherwise><div align="center">Not available</div></c:otherwise>
		  </c:choose>
		</td>
                <td class="darkValue">
                  <c:choose>
		    <c:when test="${thresholdForm.addDepMedicalDeductible != null}"> 
			<div align="center">$<c:out value="${thresholdForm.addDepMedicalDeductible}" /></div>
		    </c:when>
		    <c:otherwise><div align="center">Not available</div></c:otherwise>
  		  </c:choose>
                </td>
                <td class="darkValue"><div align="center">Not available</div></td> 
              </tr>

            </c:if>
            </table>

            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
              <tr>
                <td class="darkLabel" nowrap><fw:label property="additionalDependent" forId="additionalDependentId">Number of additional dependents (above 7):</fw:label><html-el:text styleClass="moduleEdit" property="additionalDependent" styleId="additionalDependentId" size="3" maxlength="3"/></td>
                <td class="moduleValue">
                  <table width="100%" border="0" align="center" cellspacing="0" cellpadding="0" role="presentation">
                    <tr>
                      <td><img alt=""  src="../images/buttonEndLeft.gif"/></td>
                      <td><html-el:submit property="methodName" style="width:140; vertical-align: top;" styleClass="buttonText"><bean-el:message key="button.calculateThresholds"/></html-el:submit></td>
                      <td><img alt=""  src="../images/buttonEndRight.gif"/></td>
                    </tr>
                  </table>
                </td>
                <td width="100%" class="darkValue">&nbsp;</td>
              </tr>
            </table>

            <table border="0" width="100%" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
              <tr>
                <td colspan="4" >
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellLowTableHead" role="presentation">
                    <tr>
                      <td class="moduleBrownBox"><img alt=""  src="../images/spacer.gif" width="29" height="1"/></td>
                      <td style="padding: 7 7" nowrap>Miscellaneous Thresholds</td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr valign="top">
                <td width="200" class="darkLabel"><div align="left">Net Worth:</div></td>
                <td width="200" class="darkValue"><div align="left"><esrcore:displayCurrency name="thresholdForm" currencyProperty="incomeThreshold.propertyThreshold"/></div></td>
                <td width="200" class="darkLabel"><div align="left">Child Income Exclusion:</div></td>
                <td width="200" class="darkValue"><div align="left"><esrcore:displayCurrency name="thresholdForm" currencyProperty="incomeThreshold.childIncomeExclusion"/></div></td>
              </tr>
              <tr valign="top">
	       <td class="darkLabel"><div align="left">Additional Dependent Factor:</div></td>
	       <td class="darkValue"><div align="left"><esrcore:displayCurrency name="thresholdForm" currencyProperty="incomeThreshold.addDependentThreshold"/></div></td>
	       <td class="darkLabel"><div align="left">&nbsp;</div></td>
	       <td class="darkValue"><div align="left">&nbsp;</div></td>
              </tr>
            </table>

            <table border="0" width="100%" cellpadding="0" cellspacing="0" class="moduleShellTableBody" role="presentation">
              <tr>
                <td colspan="4" >
                  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellLowTableHead" role="presentation">
                    <tr>
                      <td class="moduleBrownBox"><img alt=""  src="../images/spacer.gif" width="29" height="1"/></td>
                      <td style="padding: 7 7" nowrap>Geographical Region</td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr valign="top">
                <td class="darkLabel"><div align="left">Zip Code:</div></td>
                <td class="darkValue"><div align="left"><esrcore:displayValue name="thresholdForm" property="zipCode"/></div></td>
                <td class="darkLabel"><div align="left">FIPS Code:</div></td>
                <td class="darkValue"><div align="left"><esrcore:displayValue name="thresholdForm" property="FIPSCode"/></div></td>
              </tr>
              <tr valign="top">
                <td width="158" class="label"> <div align="left">State:</div></td>
                <td width="247" class="value"><div align="left"><esrcore:displayValue name="thresholdForm" property="state"/></div></td>
                <td width="160" class="label"><div align="left">County:</div></td>
                <td width="235" class="value"> <div align="left" class="darkValue"><esrcore:displayValue name="thresholdForm" property="county"/></div></td>
              </tr>
              <tr valign="top">
                <td class="darkLabel"><div align="left">City:</div></td>
                <td class="darkValue"><div align="left"><esrcore:displayValue name="thresholdForm" property="city"/></div></td>
                <td class="darkLabel"><div align="left"></div></td>
                <td class="darkValue"><div align="left"></div></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      </c:if>

    </td>
  </tr>
</html-el:form>
</table>
