<!--                                                                  -->
<!--  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="section" id="regionList">
			<xsl:choose>
	      <xsl:when test="count(Region) = 0">
		      <p>No regions have been created.</p>
	  	  </xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="regionListTable" />
				</xsl:otherwise>
			</xsl:choose> 
		</div>
 		<xsl:call-template name="buttons" />
  </xsl:template>
  
  <xsl:template name="regionListTable">
    <table class="textChart">
      <tr>
        <th>Name</th>
  	    <th>Countries</th>
  	    <th class="defaultCol">Default</th>
        <th class="actionsCol">Actions</th>
      </tr>
      <xsl:for-each select="Region">
      	<xsl:call-template name="regionListTableRow" />
      </xsl:for-each>
    </table>
  </xsl:template>
  
	<xsl:template name="regionListTableRow">
    <tr class="row{position() mod 2}">
      <td>
        <a href="region?RegionID={RegionID}&amp;c=show">
          <xsl:value-of select="Name" />
        </a>              		
      </td>
      <td>
				<xsl:for-each select="CountryList/CountryCodes">
					<xsl:value-of select="." /><xsl:if test="position() != last()">, </xsl:if>
				</xsl:for-each>	
      </td>
      <td class="icon">
        <xsl:if test="IsDefaultMechanicalLicenseRegion = 1">
        	<img src="/production/images/icons/office/Checkmark-(16x16).png" height="16" width="16" />
        </xsl:if>
      </td>
      <td>
        <a href="region?c=edit&amp;RegionID={RegionID}">Edit</a>
        <xsl:if test="IsDefaultMechanicalLicenseRegion = 0">, <a href="?c=set_default_mech&amp;RegionID={RegionID}">Set as Default</a></xsl:if>
      </td>
    </tr>
  </xsl:template>

</xsl:stylesheet>

