<!--                                                                  -->
<!--  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:template name="masterViewLayout">
    <xsl:if test="Params/_inline">
      <script type="text/javascript">
        addMessage('Form_Track_Master_Success','Master successfully updated!<br />');
        updateField('Form_Track_Master_Duration','<xsl:value-of select="Form/Master/Duration" />');
        updateField('Form_Track_Master_Title','<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="Form/Master/Title" /></xsl:call-template>');
        updateField('Form_Track_Master_ISRC','<xsl:value-of select="Form/Master/ISRC" />');
        updateField('Form_Track_Master_DateRecorded','<xsl:value-of select="Form/Master/DateRecorded" />');
        updateField('Form_Track_Master_ArtistName','<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="Form/Master/ArtistName" /></xsl:call-template>');
        updateField('Form_Track_Master_ArtistID','<xsl:value-of select="Form/Master/ArtistID" />');
        hidePop = 1;
      </script>
    </xsl:if>
    <xsl:if test="not(Params/_inline)">
      <xsl:call-template name="buttons" />
      <div class="section">
      <xsl:call-template name="masterView" />
      <xsl:call-template name="songView" />
      <xsl:call-template name="tracksView" />
      </div>
      <xsl:call-template name="buttons" />
    </xsl:if>
  </xsl:template>


  <xsl:template name="masterView">
    <fieldset class="section" id="masterView">
      <legend>Master</legend>
      <table class="twoRowChart">
            <tbody>
        <xsl:if test="normalize-space(Messages/Message/Code)">
          <tr> <td colspan="5"> <p class="success">Master successfully updated!</p> </td> </tr>
        </xsl:if>
        <tr>
          <th class="rowLeft">Title</th>
          <th>ISRC</th>
          <th>Artist</th>
          <th>Length</th>
          <th>Recording Date</th>
        </tr>
        <tr>
          <td class="rowLeft"><xsl:value-of select="Form/Master/Title" /></td>
          <td><xsl:value-of select="Form/Master/ISRC" /></td>
          <td><xsl:value-of select="Form/Master/ArtistName" /></td>
          <td><xsl:value-of select="Form/Master/Duration" /></td>
          <td><xsl:value-of select="Form/Master/DateRecorded" /></td>
                </tr>
                <tr>
          <td colspan="3" class="bottomRowNoBorder">
            Last modified&#160;<xsl:value-of select="Form/Master/ModifiedDate" />&#160;by&#160;<xsl:value-of select="Form/Master/ModifiedBy" />
          </td>
        </tr>
                </tbody>
      </table>
    </fieldset>
  </xsl:template>

  <xsl:template name="songView">    
    <fieldset class="section" id="songView">
      <legend>Song</legend>
      <table class="twoRowChart">
            <tbody>
        <tr>
          <th class="rowLeft">Title</th>
          <th>ISWC</th>
          <th>Composer</th>
        </tr>
        <tr>
          <td class="rowLeft"><xsl:value-of select="Form/Master/Song/Title" /></td>
          <td><xsl:value-of select="Form/Master/Song/ISWC" /></td>
          <td><xsl:value-of select="Form/Master/Song/ComposerName" /></td>
                </tr>
                <tr>
          <td colspan="3" class="bottomRowNoBorder">
            Last modified&#160;<xsl:value-of select="Form/Master/Song/ModifiedDate" />&#160;by&#160;<xsl:value-of select="Form/Master/Song/ModifiedBy" />
          </td>
        </tr>
                </tbody>
      </table>
    </fieldset>

  </xsl:template>

  <xsl:template name="tracksView">
    <fieldset class="section" id="tracksView">
      <legend>Tracks</legend>
      <table class="textChart">
        <tbody>
          <tr>
            <xsl:if test="not(Form/TrackList/Track)">
              <xsl:attribute name="class">textChartEmpty</xsl:attribute>
            </xsl:if>
            <th class="rowLeft">Name</th>
            <th>Album</th>
            <th>Artist</th>
          </tr>
          <xsl:for-each select="Form/TrackList/Track">
            <xsl:call-template name="trackViewRow" />
          </xsl:for-each>
        </tbody>
      </table>
      <xsl:if test="not(Form/TrackList/Track)">
        <p>No tracks are associated with this master.</p>
      </xsl:if>
    </fieldset>
  </xsl:template>

  <xsl:template name="trackViewRow">
      <tr class="row{position() mod 2}">
        <td class="rowLeft"><xsl:value-of select="Title" /></td>
        <td><xsl:value-of select="AlbumName" /></td>
        <td><xsl:value-of select="ArtistName" /></td>
      </tr>
  </xsl:template>

</xsl:stylesheet>

