<!--                                                                  -->
<!--  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="masterSearchLayout">
        <xsl:call-template name="searchFormInline" />
    </xsl:template>

    <xsl:template name="searchResults">
        <div class="MasterSearch">
            <h4>Search Results</h4>
            <xsl:call-template name="searchNoResult" />
            <xsl:call-template name="searchNav" >
                <xsl:with-param name="form">masterSearch</xsl:with-param>
                <xsl:with-param name="area">master</xsl:with-param>
                <xsl:with-param name="withText">true</xsl:with-param>
            </xsl:call-template>

            <div class="MasterSearch-table">

                <xsl:if test="count(Master) != 0">
                    <xsl:if test="Params/_inline">
                        <p class="MasterSearch-table-description">
                            Selecting a master will cause a song to be automatically selected.
                        </p>
                    </xsl:if>
                        <table class="Table">
                            <thead>
                                <tr class="Table-row Table-row-header">
                                    <xsl:if test="Params/_inline">
                                        <th class="Table-col Table-col-select Table-col-select-wide">Select</th>
                                    </xsl:if>
                                    <th class="Table-col MasterSearch-title-col">
                                        Title
                                    </th>
                                    <th class="Table-col MasterSearch-artist-col">Artist</th>
                                    <th class="Table-col MasterSearch-isrc-col">ISRC</th>
                                    <th class="Table-col">Length</th>
                                </tr>
                            </thead>
                        </table>

                    <div>
                        <xsl:if test="count(Master) &gt; 9">
                            <xsl:attribute name="class">Table-wrapper Table-wrapper-srolltop</xsl:attribute>
                        </xsl:if>
                        <table class="Table">
                            <tbody>
                                <xsl:for-each select="Master">
                                    <xsl:variable name="disabled">
                                        <xsl:if test="MasterID = /Root/Params/Disable">1</xsl:if>
                                    </xsl:variable>
                                    <tr class="Table-row Table-row-data">
                                        <xsl:attribute name="class">
                                            <xsl:text>Table-row Table-row-data</xsl:text>
                                            <xsl:if test="$disabled = 1">
                                                <xsl:text> Table-row-data-disabled</xsl:text>
                                            </xsl:if>
                                        </xsl:attribute>
                                        <xsl:if test="/Root/Params/_inline">
                                            <td class="Table-col Table-col-select Table-col-select-wide">
                                                <xsl:call-template name="uiRadio">
                                                    <xsl:with-param name="disabled">
                                                        <xsl:if test="$disabled = 1">
                                                            <xsl:text>true</xsl:text>
                                                        </xsl:if>
                                                    </xsl:with-param>
                                                    <xsl:with-param name="name" select="'masterMatch'"/>
                                                    <xsl:with-param name="onClick">
                                                        modifyField('selectMatch','enable');
                                                    </xsl:with-param>
                                                    <xsl:with-param name="value" select="position()"/>
                                                </xsl:call-template>
                                            </td>
                                            <script type="text/javascript">
                                                match<xsl:value-of select="position()" /> = new Object();
                                                match<xsl:value-of select="position()" />['MasterID'] = '<xsl:value-of select="MasterID" />';
                                                match<xsl:value-of select="position()" />['Title'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="Title" /></xsl:call-template>';
                                                match<xsl:value-of select="position()" />['ISRC'] = '<xsl:value-of select="ISRC" />';
                                                match<xsl:value-of select="position()" />['DateRecorded'] = '<xsl:value-of select="DateRecorded" />';
                                                match<xsl:value-of select="position()" />['ArtistName'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="ArtistName" /></xsl:call-template>';
                                                match<xsl:value-of select="position()" />['ArtistID'] = '<xsl:value-of select="ArtistID" />';
                                                match<xsl:value-of select="position()" />['Duration'] = '<xsl:value-of select="Duration" />';
                                                match<xsl:value-of select="position()" />Song = new Object();
                                                match<xsl:value-of select="position()" />Song['SongID'] = '<xsl:value-of select="Song/SongID" />';
                                                match<xsl:value-of select="position()" />Song['Title'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="Song/Title" /></xsl:call-template>';
                                                match<xsl:value-of select="position()" />Song['ISWC'] = '<xsl:value-of select="Song/ISRC" />';
                                                match<xsl:value-of select="position()" />Song['ComposerName'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="Song/ComposerName" /></xsl:call-template>';
                                                match<xsl:value-of select="position()" />Song['ComposerID'] = '<xsl:value-of select="Song/ComposerID" />';
                                                match<xsl:value-of select="position()" />['Song'] = match<xsl:value-of select="position()" />Song;
                                                matchCollection['position<xsl:value-of select="position()" />'] = match<xsl:value-of select="position()" />;
                                            </script>
                                        </xsl:if>
                                        <td class="Table-col MasterSearch-title-col">
                                            <xsl:value-of select="Title" />
                                        </td>
                                        <td class="Table-col MasterSearch-artist-col"><xsl:value-of select="ArtistName" /></td>
                                        <td class="Table-col MasterSearch-isrc-col"><xsl:value-of select="ISRC" /></td>
                                        <td class="Table-col"><xsl:value-of select="Duration" /></td>
                                    </tr>
                                </xsl:for-each>
                            </tbody>
                        </table>
                        <xsl:if test="Params/_inline">
                            <script type="text/javascript">
                                window.matchCollection = matchCollection;
                            </script>
                        </xsl:if>
                    </div>
                </xsl:if>
            </div>
            <xsl:if test="count(Master) != 0 and Params/_inline">
                <xsl:call-template name="buttons">
                    <xsl:with-param name="type" select="'stick'" />
                </xsl:call-template>
            </xsl:if>
        </div>
    </xsl:template>

</xsl:stylesheet>
