<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<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:variable name="showUS" select="/Root/ClientTypes/ClientType[ClientTypeID = 5]/IsClientTypeFlag" />
    <xsl:variable name="showCA" select="/Root/ClientTypes/ClientType[ClientTypeID = 7]/IsClientTypeFlag" />

    <xsl:template name="pickLayout">
        <div class="MainBaseSection">
            <xsl:if test="$showUS = 1">
                <xsl:call-template name="mechRateLayout">
                    <xsl:with-param name="country" select="'United States'" />
                    <xsl:with-param name="currencyCode" select="'USD'" />
                    <xsl:with-param name="statRateTypeID" select="1" />
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="$showCA = 1">
                <xsl:call-template name="mechRateLayout">
                    <xsl:with-param name="country" select="'Canadian'" />
                    <xsl:with-param name="currencyCode" select="'CAD'" />
                    <xsl:with-param name="statRateTypeID" select="2" />
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="$showUS = 1">
                <xsl:call-template name="ringRateLayout">
                    <xsl:with-param name="country" select="'United States'" />
                    <xsl:with-param name="currencyCode" select="'USD'" />
                    <xsl:with-param name="statRateTypeID" select="3" />
                </xsl:call-template>
            </xsl:if>
            <xsl:call-template name="buttons" />
        </div>
    </xsl:template>

    <xsl:template name="mechRateLayout">
        <xsl:param name="country" />
        <xsl:param name="currencyCode" />
        <xsl:param name="statRateTypeID" />
        <section class="Statrates-section">
            <h3 class="Statrates-header">
                <xsl:value-of select="$country" /> Mechanical Rates
                <xsl:call-template name="helpLink">
                    <xsl:with-param name="helpType">
                        <xsl:choose>
                            <xsl:when test="$showUS = 1">Section</xsl:when>
                            <xsl:otherwise>Page</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                    <xsl:with-param name="extraParams">&amp;country=<xsl:value-of select="$country" />
                    </xsl:with-param>
                </xsl:call-template>
            </h3>
            <table class="Table Table-with-highlight">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col">Effective Date</th>
                        <th class="Table-col Statrates-data">Base Rate (<xsl:value-of select="$currencyCode" />)</th>
                        <th class="Table-col Statrates-data">Minute Rate (<xsl:value-of select="$currencyCode" />)</th>
                    </tr>
                </thead>
                <tbody>
                    <xsl:for-each select="StatRateList/StatRate[StatRateTypeID = $statRateTypeID]">
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">
                                <xsl:choose>
                                    <xsl:when test="position() != last()">
                                        <xsl:value-of select="DateEffective" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                        Prior
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                            <td class="Table-col Statrates-data">
                                <xsl:value-of select="Rate" />
                            </td>
                            <td class="Table-col Statrates-data">
                                <xsl:choose>
                                    <xsl:when test="MinuteRate = 0">
                                        0<xsl:value-of select="/Root/Client/Locale/NumericFormat/Decimal" />0000
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="MinuteRate" />
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                        </tr>
                    </xsl:for-each>
                </tbody>
            </table>
        </section>
    </xsl:template>

    <xsl:template name="ringRateLayout">
        <xsl:param name="country" />
        <xsl:param name="currencyCode" />
        <xsl:param name="statRateTypeID" />
        <section class="Statrates-section">
            <h3 class="Statrates-header">
                <xsl:value-of select="$country" /> Ringtone Rates
                <xsl:call-template name="helpLink">
                    <xsl:with-param name="helpType" select="'Section'" />
                    <xsl:with-param name="extraParams">&amp;country=<xsl:value-of select="$country" />&amp;type=ringtone</xsl:with-param>
                </xsl:call-template>
            </h3>
            <table class="Table Table-with-highlight">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col">Effective Date</th>
                        <th class="Table-col Statrates-data">Base Rate (<xsl:value-of select="$currencyCode" />)</th>
                    </tr>
                </thead>
                <tbody>
                    <xsl:for-each select="StatRateList/StatRate[StatRateTypeID = $statRateTypeID]">
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">
                                <xsl:choose>
                                    <xsl:when test="position() != last()">
                                        <xsl:value-of select="DateEffective" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                        Current
                                    </xsl:otherwise>
                                </xsl:choose>
                            </td>
                            <td class="Table-col Statrates-data">
                                <xsl:value-of select="Rate" />
                            </td>
                        </tr>
                    </xsl:for-each>
                </tbody>
            </table>
        </section>
    </xsl:template>

    <xsl:template name="submitButton"></xsl:template>

    <xsl:template name="cancelButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Back to Admin'" />
            <xsl:with-param name="type" select="'default'" />
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="onClick">location.href='/rps/display?d=config'</xsl:with-param>
        </xsl:call-template>
    </xsl:template>

</xsl:stylesheet>
