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

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

<%@ page import='gov.va.med.esr.ui.person.action.MergeConstants' %>

<c:set var="expandableSectionCollapsed" scope="request"><bean-el:message key="label.expandableSectionCollapsed"/></c:set>
<c:set var="expandableSectionExpanded" scope="request"><bean-el:message key="label.expandableSectionExpanded"/></c:set>

<%-- Set Primary and Deprecated variables for user selections --%>
<c:set var="PRIMARY" scope="request"><%=MergeConstants.PRIMARY%></c:set>
<c:set var="DEPRECATED" scope="request"><%=MergeConstants.DEPRECATED%></c:set>

<%-- Only display information when we have a list of sections --%>
<c:if test="${sectionList != null}">

<%-- Loop through each section --%>
<c:forEach var="sectionGroupInfo" items="${sectionList}" varStatus="status">
<tr><td>&nbsp;</td></tr>
<%-- Section Header (e.g. Associates) --%>
<tr>
  <td width="29%">
    <table>
      <tr>
        <c:choose>
        <c:when test="${sectionGroupInfo.parentRow == 'true'}">
          <c:set var="expColFieldName" scope="page"><c:out value='${sectionGroupInfo.fieldName}'/>_ExpColId</c:set>
          <c:choose><c:when test='${personMergeInfoMap.person_userSelections[expColFieldName] == false}'><c:set var="imageName">Right</c:set><c:set var="altText" value="${expandableSectionCollapsed}"/></c:when><c:otherwise><c:set var="imageName">Down</c:set><c:set var="altText" value="${expandableSectionExpanded}"/></c:otherwise></c:choose>
          <th scope = "col" valign="bottom" nowrap class="moduleLabel <c:out value='${sectionGroupInfo.fieldStyle}'/>">
            <fw:link href="." onclick="expandOrCollapse(${sectionGroupInfo.fieldName}_Block, ${sectionGroupInfo.fieldName}_Image, ${sectionGroupInfo.fieldName}_ExpColId); return false">
              <html-el:img alt="${altText}" align="center" border="0" styleId="${sectionGroupInfo.fieldName}_Image" src="../images/redArrow${imageName}.gif"/><fw:label property="${sectionGroupInfo.fieldName}"><bean-el:message key="${sectionGroupInfo.fieldMessageKey}"/></fw:label>
            </fw:link>
            <input name="<c:out value='${sectionGroupInfo.fieldName}'/>_ExpColId" id="<c:out value='${sectionGroupInfo.fieldName}'/>_ExpColId" type="hidden" value="<c:choose><c:when test='${personMergeInfoMap.person_userSelections[expColFieldName] == null}'>true</c:when><c:otherwise><c:out value='${personMergeInfoMap.person_userSelections[expColFieldName]}'/></c:otherwise></c:choose>"/>
          </th>
        </c:when>
        <c:otherwise>
          <th scope = "col" valign="top" class="moduleValueBold <c:out value='${sectionGroupInfo.fieldStyle}'/>"><fw:label property="${sectionGroupInfo.fieldName}"><bean-el:message key="${sectionGroupInfo.fieldMessageKey}"/></fw:label></th>
        </c:otherwise>
        </c:choose>
      </tr>
    </table>
  </td>
  <td width="33%" valign="bottom" class="moduleValue <c:out value='${sectionGroupInfo.dataStyle}'/>"><c:if test="${sectionGroupInfo.deprecatedInputType != null}"><input type="<c:out value='${sectionGroupInfo.deprecatedInputType}'/>" title="<esrcore:displayValue name="sectionGroupInfo" property="deprecatedObject"/>&nbsp;<bean-el:message key="${sectionGroupInfo.fieldMessageKey}"/>" id="<c:out value='${sectionGroupInfo.fieldName}'/>_<c:out value="${DEPRECATED}"/>" name="<c:out value='${sectionGroupInfo.fieldName}'/>" value="<c:out value="${DEPRECATED}"/>" <c:out value="${personMergeInfoMap.person_userSelections[sectionGroupInfo.deprecatedFieldKey]}"/> <c:if test="${sectionGroupInfo.uncheckPrimaryInputType == true}">onClick="uncheckOtherBox(<c:out value='${sectionGroupInfo.fieldName}'/>_<c:out value="${DEPRECATED}"/>, <c:out value='${sectionGroupInfo.fieldName}'/>_<c:out value="${PRIMARY}"/>); return true"</c:if>></c:if><fw:spanStyle name="sectionGroupInfo" property="objectsDifferent"><esrcore:displayValue name="sectionGroupInfo" property="deprecatedObject"/></fw:spanStyle></td>
  <td width="33%" valign="bottom" class="moduleValue <c:out value='${sectionGroupInfo.dataStyle}'/>"><c:if test="${sectionGroupInfo.primaryInputType != null}"><input type="<c:out value='${sectionGroupInfo.primaryInputType}'/>" title="<esrcore:displayValue name="sectionGroupInfo" property="primaryObject"/>&nbsp;<bean-el:message key="${sectionGroupInfo.fieldMessageKey}"/>" id="<c:out value='${sectionGroupInfo.fieldName}'/>_<c:out value="${PRIMARY}"/>" name="<c:out value='${sectionGroupInfo.fieldName}'/>" value="<c:out value="${PRIMARY}"/>" <c:out value="${personMergeInfoMap.person_userSelections[sectionGroupInfo.primaryFieldKey]}"/> <c:if test="${sectionGroupInfo.uncheckDeprecatedInputType == true}">onClick="uncheckOtherBox(<c:out value='${sectionGroupInfo.fieldName}'/>_<c:out value="${PRIMARY}"/>, <c:out value='${sectionGroupInfo.fieldName}'/>_<c:out value="${DEPRECATED}"/>); return true"</c:if>></c:if><fw:spanStyle name="sectionGroupInfo" property="objectsDifferent"><esrcore:displayValue name="sectionGroupInfo" property="primaryObject"/></fw:spanStyle></td>
  <td width="5%" class="moduleValue">&nbsp;</td>
</tr>
<tr id="<c:out value='${sectionGroupInfo.fieldName}'/>_Block" style="display:<c:choose><c:when test='${personMergeInfoMap.person_userSelections[expColFieldName] == false}'>none</c:when><c:otherwise>block</c:otherwise></c:choose>">
  <td colspan="4">
    <table rules="all" class="TableDisplay">
    <%-- Children of section --%>
    <c:forEach var="sectionChild" items="${sectionGroupInfo.children}">
      <c:set var="sectionChildReq" scope="request" value="${sectionChild}"/>
      <c:choose>
      <c:when test="${sectionChild.parentRow == 'true'}">

        <%-- Initial collection header row (e.g. Associates Details) --%>
        <tr>
          <td width="29%">
            <table>
              <tr>
                <c:set var="expColFieldName" scope="page"><c:out value='${sectionChild.fieldName}'/>_ExpColId</c:set>
                <c:choose><c:when test='${personMergeInfoMap.person_userSelections[expColFieldName] == false}'><c:set var="imageName">Right</c:set><c:set var="altText" value="${expandableSectionCollapsed}"/></c:when><c:otherwise><c:set var="imageName">Down</c:set><c:set var="altText" value="${expandableSectionExpanded}"/></c:otherwise></c:choose>
                <th scope = "col" nowrap class="moduleLabel <c:out value='${sectionChild.fieldStyle}'/>">
                  <fw:link href="." onclick="expandOrCollapse(${sectionChild.fieldName}_Block, ${sectionChild.fieldName}_Image, ${sectionChild.fieldName}_ExpColId); return false">
                    <html-el:img alt="${altText}" align="center" border="0" styleId="${sectionChild.fieldName}_Image" src="../images/redArrow${imageName}.gif"/><fw:label property="${sectionChild.fieldName}"><bean-el:message key="${sectionChild.fieldMessageKey}"/></fw:label>
                  </fw:link>
                  <input name="<c:out value='${sectionChild.fieldName}'/>_ExpColId" id="<c:out value='${sectionChild.fieldName}'/>_ExpColId" type="hidden" value="<c:choose><c:when test='${personMergeInfoMap.person_userSelections[expColFieldName] == null}'>true</c:when><c:otherwise><c:out value='${personMergeInfoMap.person_userSelections[expColFieldName]}'/></c:otherwise></c:choose>"/>
                </th>
              </tr>
            </table>
          </td>
          <td width="33%" class="moduleValue <c:out value='${sectionChild.dataStyle}'/>"><c:if test="${sectionChild.deprecatedInputType != null}"><input type="<c:out value='${sectionChild.deprecatedInputType}'/>" title="<esrcore:displayValue name="sectionChild" property="deprecatedObject"/>" id="<c:out value='${sectionChild.fieldName}'/>_<c:out value="${DEPRECATED}"/>" name="<c:out value='${sectionChild.fieldName}'/>" value="<c:out value="${DEPRECATED}"/>" <c:out value="${personMergeInfoMap.person_userSelections[sectionChild.deprecatedFieldKey]}"/> <c:if test="${sectionChild.uncheckPrimaryInputType == true}">onClick="uncheckOtherBox(<c:out value='${sectionChild.fieldName}'/>_<c:out value="${DEPRECATED}"/>, <c:out value='${sectionChild.fieldName}'/>_<c:out value="${PRIMARY}"/>); return true"</c:if>></c:if><fw:spanStyle name="sectionChild" property="objectsDifferent"><esrcore:displayValue name="sectionChild" property="deprecatedObject"/></fw:spanStyle></td>
          <td width="33%" class="moduleValue <c:out value='${sectionChild.dataStyle}'/>"><c:if test="${sectionChild.primaryInputType != null}"><input type="<c:out value='${sectionChild.primaryInputType}'/>" title="<esrcore:displayValue name="sectionChild" property="primaryObject"/>" id="<c:out value='${sectionChild.fieldName}'/>_<c:out value="${PRIMARY}"/>" name="<c:out value='${sectionChild.fieldName}'/>" value="<c:out value="${PRIMARY}"/>" <c:out value="${personMergeInfoMap.person_userSelections[sectionChild.primaryFieldKey]}"/> <c:if test="${sectionChild.uncheckDeprecatedInputType == true}">onClick="uncheckOtherBox(<c:out value='${sectionChild.fieldName}'/>_<c:out value="${PRIMARY}"/>, <c:out value='${sectionChild.fieldName}'/>_<c:out value="${DEPRECATED}"/>); return true"</c:if>></c:if><fw:spanStyle name="sectionChild" property="objectsDifferent"><esrcore:displayValue name="sectionChild" property="primaryObject"/></fw:spanStyle></td>
          <td valign="top" width="5%"   class="moduleValue" style="text-align: left; padding-left: 10"><c:if test="${sectionChild.objectsDifferent}"><html-el:img alt="${dataChanged}" align="center" border="0" styleId="rdImage" src="../images/data_changed.gif"/></c:if></td>
        </tr>
        <tr id="<c:out value='${sectionChild.fieldName}'/>_Block" style="display:<c:choose><c:when test='${personMergeInfoMap.person_userSelections[expColFieldName] == false}'>none</c:when><c:otherwise>block</c:otherwise></c:choose>">
          <td colspan="4">
            <table rules="all" class="TableDisplay" frame="void">
         	    <jsp:include page="displayMergeFieldsCollection.jsp" flush="true" />
            </table>
          </td>
        </tr>


      </c:when>
      <c:otherwise>
        <%-- Non-collection child of section (e.g. Sensitivity Flag) --%>
        <tr>
          <th scope = "col" nowrap valign="top" width="29%" class="moduleValueBold <c:out value='${sectionChild.fieldStyle}'/>"><fw:label property="${sectionChild.fieldName}"><bean-el:message key="${sectionChild.fieldMessageKey}"/></fw:label></th>
          <td valign="top" width="33%" class="moduleValue <c:out value='${sectionChild.dataStyle}'/>"><c:if test="${sectionChild.deprecatedInputType != null}"><input type="<c:out value='${sectionChild.deprecatedInputType}'/>" title="<esrcore:displayValue name="sectionChild" property="deprecatedObject"/>&nbsp;<bean-el:message key="${sectionChild.fieldMessageKey}"/>" id="<c:out value='${sectionChild.fieldName}'/>_<c:out value="${DEPRECATED}"/>" name="<c:out value='${sectionChild.fieldName}'/>" value="<c:out value="${DEPRECATED}" />" <c:out value="${personMergeInfoMap.person_userSelections[sectionChild.deprecatedFieldKey]}"/> <c:if test="${sectionChild.uncheckPrimaryInputType == true}">onClick="uncheckOtherBox(<c:out value='${sectionChild.fieldName}'/>_<c:out value="${DEPRECATED}"/>, <c:out value='${sectionChild.fieldName}'/>_<c:out value="${PRIMARY}"/>); return true"</c:if>></c:if><fw:spanStyle name="sectionChild" property="objectsDifferent"><esrcore:displayValue name="sectionChild" property="deprecatedObject"/></fw:spanStyle></td>
          <td valign="top" width="33%" class="moduleValue <c:out value='${sectionChild.dataStyle}'/>"><c:if test="${sectionChild.primaryInputType != null}"><input type="<c:out value='${sectionChild.primaryInputType}'/>" title="<esrcore:displayValue name="sectionChild" property="primaryObject"/>&nbsp;<bean-el:message key="${sectionChild.fieldMessageKey}"/>" id="<c:out value='${sectionChild.fieldName}'/>_<c:out value="${PRIMARY}"/>" name="<c:out value='${sectionChild.fieldName}'/>" value="<c:out value="${PRIMARY}" />" <c:out value="${personMergeInfoMap.person_userSelections[sectionChild.primaryFieldKey]}"/> <c:if test="${sectionChild.uncheckDeprecatedInputType == true}">onClick="uncheckOtherBox(<c:out value='${sectionChild.fieldName}'/>_<c:out value="${PRIMARY}"/>, <c:out value='${sectionChild.fieldName}'/>_<c:out value="${DEPRECATED}"/>); return true"</c:if>></c:if><fw:spanStyle name="sectionChild" property="objectsDifferent"><esrcore:displayValue name="sectionChild" property="primaryObject"/></fw:spanStyle></td>
          <td valign="top" width="5%"   class="moduleValue" style="text-align: left; padding-left: 10"><c:if test="${sectionChild.objectsDifferent}"><html-el:img alt="${dataChanged}" align="center" border="0" styleId="rdImage" src="../images/data_changed.gif"/></c:if></td>
        </tr>
      </c:otherwise>
      </c:choose>
    </c:forEach>

    </table>
  </td>
</tr>
</c:forEach>

</c:if>
