<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template name="regionListLayout">
        <div class="MainBaseSection">
            <xsl:choose>
                <xsl:when test="count(Region) = 0">
                    <div class="Table-empty-results">
                        <p>No regions have been created.</p>
                    </div>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="regionListTable" />
                </xsl:otherwise>
            </xsl:choose>
            <xsl:call-template name="buttons" />
        </div>
    </xsl:template>

    <xsl:template name="regionListTable">
        <table class="Table Table-regionlist">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col Table-col-name">Name</th>
                    <th class="Table-col Table-col-biglist">Countries</th>
                    <th class="Table-col Table-col-default">Default</th>
                    <th class="Table-col Table-col-actions">Actions</th>
                    <th class="Table-col Table-col-icon">Edit</th>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="Region">
                    <xsl:call-template name="regionListTableRow" />
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>

    <xsl:template name="regionListTableRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col Table-col-name">
                <a href="region?RegionID={RegionID}&amp;c=show">
                    <xsl:value-of select="Name" />
                </a>
            </td>
            <td class="Table-col Table-col-biglist">
                <xsl:for-each select="CountryList/CountryCodes">
                    <xsl:value-of select="." />
                    <xsl:if test="position() != last()">, </xsl:if>
                </xsl:for-each>
            </td>
            <td class="Table-col Table-col-default">
                <xsl:if test="IsDefaultMechanicalLicenseRegion = 1">
                    <xsl:call-template name="icon">
                        <xsl:with-param name="type" select="'complete'" />
                        <xsl:with-param name="size" select="'medium'" />
                        <xsl:with-param name="className" select="'List-default'" />
                    </xsl:call-template>
                </xsl:if>
            </td>
            <td class="Table-col Table-col-actions">
                <xsl:if test="IsDefaultMechanicalLicenseRegion = 0">
                    <a href="?c=set_default_mech&amp;RegionID={RegionID}">Set&#160;as&#160;Default</a>
                </xsl:if>
            </td>
            <td class="Table-col Table-col-icon">
                <a href="region?c=edit&amp;RegionID={RegionID}">
                    <xsl:call-template name="icon">
                        <xsl:with-param name="type" select="'edit'" />
                        <xsl:with-param name="role" select="'action'" />
                    </xsl:call-template>
                </a>
            </td>
        </tr>
    </xsl:template>

</xsl:stylesheet>

