<!--  $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 Details</xsl:with-param>
    </xsl:call-template>
    <xsl:call-template name="bodyMessage" />
    <xsl:call-template name="displayForm" />
    <xsl:call-template name="displayButtons" />
  </xsl:template>

  <xsl:template name="displayForm" >
    <div name="body_form">
      <xsl:choose>
        <xsl:when test="Form/ClientID &gt; 0">
          <xsl:call-template name="displayDetail" />
        </xsl:when>
        <xsl:otherwise>
          Client not found
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>

  <xsl:template name="displayDetail" >
    <form method="post" action="{$moduleURL}" >
      <input type="hidden" name="c"><xsl:attribute name="value"><xsl:value-of select="/Root/Cmd" /></xsl:attribute></input>
      <input type="hidden" name="ClientID"><xsl:attribute name="value"><xsl:value-of select="Form/ClientID" /></xsl:attribute></input>
      <input type="hidden" name="action"><xsl:attribute name="value"><xsl:value-of select="Params/action" /></xsl:attribute></input>
      <table>

        <tr class="row1">
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Client Name</xsl:with-param>
            <xsl:with-param name="value" select = "Form/ClientName" />
          </xsl:call-template>
        </tr>

        <tr>
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Client ID</xsl:with-param>
            <xsl:with-param name="value" select = "Form/ClientID" />
          </xsl:call-template>
        </tr>

        <tr class="row1">
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Client Type</xsl:with-param>
            <xsl:with-param name="value">
                <xsl:if test="Form/RPS">RPS</xsl:if>
                <xsl:if test="Form/BookPub">DTMV</xsl:if>
            </xsl:with-param>
          </xsl:call-template>
        </tr>

        <tr>
          <xsl:variable name="url">
            <xsl:choose>
                <xsl:when test="normalize-space(Form/WebAlias)">
                    <xsl:value-of select="Form/WebAlias" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="Form/ClientNameClean" />
                </xsl:otherwise>
            </xsl:choose>.royaltyshare.com</xsl:variable>
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">URL</xsl:with-param>
            <xsl:with-param name="url" select="$url" />
          </xsl:call-template>
        </tr>

        <tr class="row1">
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Country Code</xsl:with-param>
            <xsl:with-param name="value" select = "Form/CountryCode" />
          </xsl:call-template>
        </tr>

        <tr>
          <xsl:call-template name="textField" >
            <xsl:with-param name="label">Language Code</xsl:with-param>
            <xsl:with-param name="value" select = "Form/LanguageCode" />
          </xsl:call-template>
        </tr>

        <xsl:if test="Form/BookPub">
            <tr class="row1">
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">Price Validation</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/PriceValidation = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
            <tr>
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">Alternate Conversion</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/AlternateConversion = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
        </xsl:if>

        <xsl:if test="Form/RPS">
            <tr class="row1">
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">Artist Royalties</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/ArtistRoyalties = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
            <tr>
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">Label Royalties</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/LabelRoyalties = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
            <tr class="row1">
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">US Mechanicals</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/USMechanicals = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
            <tr>
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">UK Mechanicals</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/UKMechanicals = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
            <tr class="row1">
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">CA Mechanicals</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/CAMechanicals = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
            <tr>
                <xsl:call-template name="textField" >
                    <xsl:with-param name="label">Payee Portal</xsl:with-param>
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="Form/PayeePortal = 1">Yes</xsl:when>
                            <xsl:otherwise>No</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>
            </tr>
        </xsl:if>

      </table>

      <br />

      <fieldset>
        <legend>Client Options</legend>
        <xsl:choose>
            <xsl:when test="count(Form/ClientOptions/*) = 0">
                <p style="margin-left: 10px">N/A</p>
            </xsl:when>
            <xsl:otherwise>
                <table>
                    <xsl:for-each select="Form/ClientOptions/*" >
                        <xsl:sort select="local-name()" />
                        <tr class="row{position() mod 2}">
                            <xsl:call-template name="textField" >
                                <xsl:with-param name="label"><xsl:value-of select="local-name()" /></xsl:with-param>
                                <xsl:with-param name="value" select = "." />
                            </xsl:call-template>
                        </tr>      
                    </xsl:for-each>
                </table>
            </xsl:otherwise>
        </xsl:choose>
      </fieldset>

    </form>
  </xsl:template>

  <xsl:template name="displayButtons" >
      <xsl:call-template name="backButton" >
        <xsl:with-param name="buttonText">Return to Client Search</xsl:with-param>
        <xsl:with-param name="command" >clients</xsl:with-param>
      </xsl:call-template>
  </xsl:template>

</xsl:stylesheet>
