<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:include href="/app/tools/support/templates/layout.xsl" />

  <xsl:template name="mainBody" >
    <xsl:call-template name="bodyTitle" >
      <xsl:with-param name="title">Client Search</xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="collectionSearch" >
      <xsl:with-param name="listCommand">client_list</xsl:with-param>
    </xsl:call-template>

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


  <xsl:template name="displayList" >

    <xsl:choose>

      <xsl:when test="Collection/List/Item">
        <xsl:call-template name="displayListBody" />
      </xsl:when>

      <xsl:otherwise>
        <xsl:call-template name="collectionListEmpty" />
      </xsl:otherwise>

    </xsl:choose>

  </xsl:template>

  <xsl:template name="displayListBody" >
    <xsl:call-template name="collectionListPagination" />

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

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

  <xsl:template name="displayClientList" >
    <table class="dataset">
      <tbody>
        <tr class="header">
          <th>Client Name</th>
          <th>Client ID</th>
          <th>Client Type</th>
          <th>URL</th>
          <th>Country Code</th>
          <th>Language Code</th>
        </tr>

        <xsl:for-each select="Collection/List/Item" >
          <xsl:call-template name="displayClientRow" />
        </xsl:for-each>
      </tbody>
    </table>
  </xsl:template>

  <xsl:template name="displayClientRow" >

    <xsl:variable name="url">
      <xsl:choose>
        <xsl:when test="normalize-space(WebAlias)">
          <xsl:value-of select="WebAlias" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="ClientNameClean" />
        </xsl:otherwise>
      </xsl:choose>.royaltyshare.com</xsl:variable>

    <tr class="row{position() mod 2}">
      <td><xsl:value-of select="ClientName" /></td>
      <td><xsl:value-of select="ClientID" /></td>
      <td>
        <xsl:if test="RPS">RPS</xsl:if>
        <xsl:if test="BookPub">DTMV</xsl:if>
      </td>
      <td>
        <a href="https://{$url}" target="_blank">
            <xsl:value-of select="$url" />
        </a>
      </td>
      <td><xsl:value-of select="CountryCode" /></td>
      <td><xsl:value-of select="LanguageCode" /></td>
      <td><a href="https://{$url}{$moduleURL}?c=client_detail&amp;ClientID={ClientID}">More Details</a></td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
