<!--                                                                  -->
<!--  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="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" 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>
        
            <xsl:if test="$showUS = 1">
            
                <xsl:attribute name="class">twoSections</xsl:attribute>

                <xsl:call-template name="mechRateLayout">
                    <xsl:with-param name="class" select="'sectionLeft'" />
                    <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="class">
                        section<xsl:if test="$showUS = 1">Right</xsl:if>
                    </xsl:with-param>                
                    <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:if test="$showCA = 1">
                    <br class="superBreak" />
                    <br />
                </xsl:if>
                
                <xsl:call-template name="ringRateLayout">
                    <xsl:with-param name="class">
                        <xsl:choose>
                            <xsl:when test="$showCA = 1">sectionLeft</xsl:when>
                            <xsl:otherwise>sectionRight</xsl:otherwise>
                        </xsl:choose>    
                    </xsl:with-param>      
                    <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>            
        
        </div>

        <xsl:call-template name="buttons" />
        
    </xsl:template>


    <xsl:template name="mechRateLayout">
        <xsl:param name="class" />
        <xsl:param name="country" />
        <xsl:param name="currencyCode" />
        <xsl:param name="statRateTypeID" />
        <div class="{$class}">
            <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>
            <xsl:if test="$showUS = 1">
                <br />
            </xsl:if>
            <h2><xsl:value-of select="$country" /> Mechanical Rates</h2>
            <table class="textChart hiOn">
                <tr>
                    <th>Effective Date</th>
                    <th class="amount">Base Rate (<xsl:value-of select="$currencyCode" />)</th>
                    <th class="amount">Minute Rate (<xsl:value-of select="$currencyCode" />)</th>
                </tr>
                <xsl:for-each select="StatRateList/StatRate[StatRateTypeID = $statRateTypeID]">
                    <tr class="row{position()  mod 2}">
                        <td>
                            <xsl:choose>
                                <xsl:when test="position() != last()">
                                    <xsl:value-of select="DateEffective" />
                                </xsl:when>
                                <xsl:otherwise>
                                    Prior
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td class="amount">
                            <xsl:value-of select="Rate" />
                        </td>
                        <td class="amount">
                            <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>
            </table>
        </div>	
    </xsl:template>
    
    
    <xsl:template name="ringRateLayout">
        <xsl:param name="class" />
        <xsl:param name="country" />
        <xsl:param name="currencyCode" />
        <xsl:param name="statRateTypeID" />
        <div class="{$class} ringStatRates">
            <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>
            <br />
            <h2><xsl:value-of select="$country" /> Ringtone Rates</h2>
            <table class="textChart hiOn">
                <tr>
                    <th>Effective Date</th>
                    <th class="amount">Base Rate (<xsl:value-of select="$currencyCode" />)</th>
                </tr>
                <xsl:for-each select="StatRateList/StatRate[StatRateTypeID = $statRateTypeID]">
                    <tr class="row{position()  mod 2}">
                        <td>
                            <xsl:choose>
                                <xsl:when test="position() != last()">
                                    <xsl:value-of select="DateEffective" />
                                </xsl:when>
                                <xsl:otherwise>
                                    Current
                                </xsl:otherwise>
                            </xsl:choose>
                        </td>
                        <td class="amount">
                            <xsl:value-of select="Rate" />
                        </td>
                    </tr>
                </xsl:for-each>
            </table>
        </div>	
    </xsl:template>    


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


	<xsl:template name="cancelButton">
		<input type="button" name="Back" value="Back to Admin" onClick="location.href='/rps/display?d=config'" />
	</xsl:template>


</xsl:stylesheet>

