<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn">
    <xsl:output method="html" indent="no" doctype-system="" encoding="utf-8" />

    <xsl:include href="/app/tools/rps/templates/global.xsl" />
    <xsl:include href="shared.xsl" />
    <xsl:include href="/app/tools/common/production/templates/list_nav.xsl" />

    <xsl:template name="pickLayout">
        <link href="/production/css/rps/paginated_statements.css?v=1" rel="stylesheet" type="text/css" />
        <div class="MainBaseSection">
        <xsl:call-template name="helpLink" />

        <xsl:if test="Statement/Pagination/NumPages &gt; 1">
            <div class="Table-controls Table-controls-top">
                <div class="Table-controls-item Table-controls-item-pagination">
                    <xsl:call-template name="numericListNav">
                        <xsl:with-param name="pagination">/Root/Statement/Pagination</xsl:with-param>
                        <xsl:with-param name="extraParams">&amp;MechanicalStatementID=<xsl:value-of select="/Root/Params/MechanicalStatementID" /></xsl:with-param>
                    </xsl:call-template>
                </div>
            </div>
        </xsl:if>

        <xsl:for-each select="Statement/Table">
            <div class="Table-wrapper StatementsDocuments-list-tabel-item">
                <xsl:call-template name="statementTable" />
            </div>
        </xsl:for-each>

        <fieldset class="Form-fieldset Form-fieldset-buttons">
            <xsl:call-template name="uiButton">
                <xsl:with-param name="content" select="'Back to Statements'" />
                <xsl:with-param name="className" select="'Form-button'" />
                <xsl:with-param name="name" select="'Back'" />
                <xsl:with-param name="url">
                    <xsl:value-of select="$mechArea" />
                    <xsl:text>mechanical?MechanicalRunID=</xsl:text>
                    <xsl:value-of select="Run/MechanicalRunID" />
                    <xsl:text>&amp;c=show&amp;PayorID=</xsl:text>
                    <xsl:value-of select="Run/PayorID" />
                </xsl:with-param>
            </xsl:call-template>
        </fieldset>

        </div>
    </xsl:template>


    <xsl:template name="statementTable">
        <table class="{Class} Table">
            <tbody>
                <xsl:for-each select="Row">
                    <tr class="{Class} Table-row Table-row-data">
                        <xsl:for-each select="Cell">
                            <xsl:call-template name="statementCell">
                                <xsl:with-param name="cell" select="." />
                            </xsl:call-template>
                        </xsl:for-each>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>

    <xsl:template name="statementCell">
        <xsl:param name="cell" />
        <td class="{$cell/Class} Table-col">
            <xsl:choose>
                <xsl:when test="$cell/Class = 'SUBTOTAL_ROW'">
                    <xsl:attribute name="colspan">20</xsl:attribute>
                </xsl:when>
                <xsl:when test="$cell/Class = 'PUBLISHER_ROW'">
                    <xsl:attribute name="colspan">20</xsl:attribute>
                </xsl:when>
                <xsl:when test="$cell/Class = 'BLANK_ROW'">
                    <xsl:attribute name="colspan">21</xsl:attribute>
                </xsl:when>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="normalize-space($cell/LinkValue) or normalize-space($cell/TitleValue)">
                    <a>
                        <xsl:if test="normalize-space($cell/LinkValue)">
                            <xsl:attribute name="href"><xsl:value-of select="$cell/LinkValue" /></xsl:attribute>
                        </xsl:if>
                        <xsl:if test="normalize-space($cell/TitleValue)">
                            <xsl:attribute name="title"><xsl:value-of select="$cell/TitleValue" /></xsl:attribute>
                        </xsl:if>
                        <xsl:value-of select="$cell/DisplayValue" disable-output-escaping="yes" />
                    </a>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$cell/DisplayValue" disable-output-escaping="yes" />
                </xsl:otherwise>
            </xsl:choose>
        </td>
    </xsl:template>


</xsl:stylesheet>

