<script type="text/javascript" language="JavaScript" src="../scripts/ESR-Script.js"></script>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ 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/fw" prefix="fw" %>

<%--
  ***** TODO *****
  Add links to site messages
  <a href="/esr/facility/hl7Message.do?methodName=displaySiteMessages" paramId="selectedSiteId" paramProperty="selectedSiteId">
--%>

<c:set var="viewFormattedText"><bean-el:message key="button.viewFormatted"/></c:set>
<c:set var="viewUnformattedText"><bean-el:message key="button.viewUnformatted"/></c:set>
<c:set var="formattedRawMessageText"><bean-el:message key="label.formattedRawMessage"/></c:set>
<c:set var="unformattedRawMessageText"><bean-el:message key="label.unformattedRawMessage"/></c:set>

<script type="text/javascript">
// Expands or collapses a section by toggling the existing section state.
function swapViewableSection(button, formattedBlock, formattedText, unformattedBlock, unformattedText)
{
  var formatBlock = document.getElementById('formattedBlock');
  var unformatBlock = document.getElementById('unformattedBlock');

  if (formatBlock.style.display == "block")
  {
    formatBlock.style.display = 'none';
    unformatBlock.style.display = 'block';
    button.value = formattedText;
  }
  else
  {
    formatBlock.style.display = 'block';
    unformatBlock.style.display = 'none';
    button.value = unformattedText;
  }
}
</script>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShell" role="presentation">
  <tr>
    <td>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="moduleShellTable" role="presentation">
        <tr>
          <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" style="padding-top: 2px; padding-bottom: 2px" class="moduleShellTableHead" role="presentation">
              <tr>
                <td class="moduleBlueBox"><img alt=""  src="../images/spacer.gif" width="25" height="17"/></td>
                <td nowrap style="padding-left: 7px; padding-right: 8px"><c:out value="${selectedMessage.type.code}"/>: <c:out value="${selectedMessage.type.description}"/> - Raw Data </td>
                <td width="100%"><img alt=""  src="../images/spacer.gif"/></td>
                <td><img alt="" src="../images/buttonEndLeft.gif"/></td>
                <td>
                  <html-el:button property="methodName" style="width:110; vertical-align: top;" styleClass="buttonText"
                    onclick="swapViewableSection(this, 'formattedBlock', '${viewFormattedText}', 'unformattedBlock', '${viewUnformattedText}'); return false">
                    <bean-el:message key="button.viewUnformatted"/>
                  </html-el:button>
                </td>
                <td style="padding-right: 5"><img alt=""  src="../images/buttonEndRight.gif"/></td>
                <td nowrap class="moduleBlueLink" style="padding: 1px 8px 1px 8px"><fw:link action="messageAction?methodName=FIND"><bean-el:message key="label.message.backToMessageLog"/></fw:link></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td width="100%" class="moduleShellTableBody">
            <table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation">
              <tr>
                <td width="100%" class="moduleShellTableBody">
                  <div id="unformattedBlock" style="display:none">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation">
                      <tr>
                        <td class="moduleValue">
                          <fw:label property="unformattedRawMessageText" forId="unformattedMessageId"><span style="display:none">unformattedMessageId</span></fw:label>
                     	  <textarea title="<c:out value='${unformattedRawMessageText}'/>"  id="unformattedMessageId" wrap="off" cols="108" rows="<c:out value='${unformattedMessageRows}'/>"><c:out value="${unformattedMessage}"/></textarea>
                        </td>
                      </tr>
                    </table>
                  </div>
                  <div id="formattedBlock" style="display:block">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation">
                      <tr>
                        <td class="moduleValue">
                          <fw:label property="formattedRawMessageText" forId="formattedMessageId"><span style="display:none">formattedMessageId</span></fw:label>
                    	  <textarea title="<c:out value='${formattedRawMessageText}'/>" wrap="off" cols="108" id="formattedMessageId" rows="<c:out value='${formattedMessageRows}'/>"><c:out value="${formattedMessage}"/></textarea>
                        </td>
                      </tr>
                    </table>
                  </div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
