<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


    <xsl:variable name="showDistTab">
        <xsl:if test="/Root/Access/rps/product/show_digital">1</xsl:if>
    </xsl:variable>


    <xsl:variable name="isDistClient" select="/Root/ClientTypes/ClientType[ClientTypeID = 4]/IsClientTypeFlag" />


    <xsl:variable name="showTabs">
        <xsl:choose>
            <xsl:when test="/Root/Access/rps/catalog/show_contracts or /Root/Access/rps/catalog/show_licenses or /Root/Access/rps/catalog/show_uk_licenses or /Root/Access/rps/catalog/show_ca_licenses or $showDistTab = 1">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>


    <xsl:template name="catalogViewLayout">

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

        <script type="text/javascript">

            var mainTab        = new Object();
            mainTab.url        = "/rps/catalog?c=show_main&amp;AlbumID=<xsl:value-of select="Form/Album/AlbumID" />";
            mainTab.id         = "mainTab";
            mainTab.text       = "Main";
            mainTab.visible    = "<xsl:value-of select="Access/rps/catalog/show_main" />";
            mainTab.enabled    = "1";
            mainTab.show_count = "0";

            var contractTab        = new Object();
            contractTab.url        = "/rps/catalog?c=show_contracts&amp;simplified=1&amp;AlbumID=<xsl:value-of select="Form/Album/AlbumID" />";
            contractTab.id         = "contractTab";
            contractTab.text       = "Contracts";
            contractTab.visible    = "<xsl:value-of select="Access/rps/catalog/show_contracts" />";
            contractTab.enabled    = "1";
            contractTab.show_count = "1";

            var caLicenseTab        = new Object();
            caLicenseTab.url        = "/rps/catalog?c=show_ca_licenses&amp;AlbumID=<xsl:value-of select="Form/Album/AlbumID" />";
            caLicenseTab.id         = "caLicenseTab";
            caLicenseTab.text       = "CA Licenses";
            caLicenseTab.visible    = "<xsl:value-of select="Access/rps/catalog/show_ca_licenses" />";
            caLicenseTab.enabled    = "1";
            caLicenseTab.show_count = "1";

            var ukLicenseTab        = new Object();
            ukLicenseTab.url        = "/rps/catalog?c=show_uk_licenses&amp;AlbumID=<xsl:value-of select="Form/Album/AlbumID" />";
            ukLicenseTab.id         = "ukLicenseTab";
            ukLicenseTab.text       = "UK Licenses";
            ukLicenseTab.visible    = "<xsl:value-of select="Access/rps/catalog/show_uk_licenses" />";
            ukLicenseTab.enabled    = "1";
            ukLicenseTab.show_count = "1";

            var licenseTab        = new Object();
            licenseTab.url        = "/rps/catalog?c=show_licenses&amp;AlbumID=<xsl:value-of select="Form/Album/AlbumID" />";
            licenseTab.id         = "licenseTab";
            licenseTab.text       = "US Licenses";
            licenseTab.visible    = "<xsl:value-of select="Access/rps/catalog/show_licenses" />";
            licenseTab.enabled    = "1";
            licenseTab.show_count = "1";

            var distributionTab        = new Object();
            distributionTab.url        = "/rps/product?c=show_digital&amp;AlbumID=<xsl:value-of select="Form/Album/AlbumID" />";
            distributionTab.id         = "distributionTab";
            distributionTab.text       = "Distribution";
            distributionTab.visible    = "<xsl:value-of select="$showDistTab" />";
            distributionTab.enabled    = "1";
            distributionTab.show_count = "1";


            var aTabs = new Array(mainTab, contractTab, caLicenseTab, ukLicenseTab, licenseTab, distributionTab);
            var oTabUpdateObj = new RSCatalogTabOnclickUpdate("mainCatalogPanel", "catalogNav", aTabs);

            <xsl:choose>
                <xsl:when test="Params/tab = 'distributionTab'">
                    oTabUpdateObj.ActivateTab('distributionTab');
                </xsl:when>
                <xsl:when test="Params/tab = 'contractTab'">
                    oTabUpdateObj.ActivateTab('contractTab');
                </xsl:when>
                <xsl:when test="Params/tab = 'licenseTab'">
                    oTabUpdateObj.ActivateTab('licenseTab');
                </xsl:when>
                <xsl:when test="Params/tab = 'ukLicenseTab'">
                    oTabUpdateObj.ActivateTab('ukLicenseTab');
                </xsl:when>
                <xsl:when test="Params/tab = 'caLicenseTab'">
                    oTabUpdateObj.ActivateTab('caLicenseTab');
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>oTabUpdateObj.ActivateTab('mainTab', 'page=</xsl:text>
                    <xsl:value-of select="Params/page" />
                    <xsl:text>');</xsl:text>
                </xsl:otherwise>
            </xsl:choose>

            function displayErrorReport() {
            displayInline('/rps/catalog?AlbumID=<xsl:value-of select="Form/Album/AlbumID" />&amp;c=error_report');
            }

            <xsl:if test="Params/error_report">
                // allow the error report to pop up automatically
                addEvent(window, 'load', displayErrorReport, false);
            </xsl:if>

        </script>
    </xsl:template>


    <xsl:template name="catalogView">

        <div id="catalog-music-album" class="Album-information">
            <xsl:call-template name="successMessageGeneral">
                <xsl:with-param name="successMessage">Album successfully updated!</xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="albumDetailView" />
        </div>

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

        <div class="Album-tracks">
            <div id="mainCatalogPanel" class="js-rs-html-content">
            </div>
            <xsl:call-template name="buttons" />
        </div>

    </xsl:template>


    <xsl:template name="catalogViewTabs">
        <div class="sectionNav Album-navigation">
            <xsl:if test="$showTabs != 1">
                <xsl:attribute name="style">display: none</xsl:attribute>
            </xsl:if>
            <ul class="SubNavigation-list" id="catalogNav"></ul>
        </div>
    </xsl:template>


    <xsl:template name="albumDetailView">
        <div id="albumView">
            <div class="Album-header-container">
                <h2 class="Album-header-text">Album</h2>

                <div class="Album-details-column Album-details-edit-button-wrapper">

                    <xsl:if test="Access/rps/catalog/edit">
                        <xsl:call-template name="uiButton">
                            <xsl:with-param name="content" select="'Edit Album'" />
                            <xsl:with-param name="url">
                                <xsl:text>catalog?AlbumID=</xsl:text>
                                <xsl:value-of select="Form/Album/AlbumID" />
                                <xsl:text>&amp;c=edit</xsl:text>
                            </xsl:with-param>
                        </xsl:call-template>
                    </xsl:if>
                </div>
            </div>
            <div class="Album-details-wrapper">

                <div class="Album-details-column Album-details-column-fields">
                    <div class="ValuePair">

                        <div class="ValuePair-item">
                            <div class="ValuePair-label">Title</div>
                            <div class="ValuePair-value">
                                <xsl:value-of select="Form/Album/Title" /><xsl:if test="normalize-space(Form/Album/TitleVersion)">&#160;(<xsl:value-of select="Form/Album/TitleVersion" />)</xsl:if>
                            </div>
                        </div>

                        <div class="ValuePair-item">
                            <div class="ValuePair-label">Artist</div>
                            <div class="ValuePair-value">
                                <xsl:value-of select="Form/Album/ArtistName" />
                                <xsl:if test="count(Form/Album/AdditionalArtistList/AdditionalArtist) != 0">
                                    &#160;<a class="js-tooltip">
                                        <xsl:attribute name="title">
                                            <xsl:for-each select="Form/Album/AdditionalArtistList/AdditionalArtist">
                                                <xsl:sort select="AdditionalArtistID" data-type="number" />
                                                <xsl:call-template name="escapeJavascript">
                                                    <xsl:with-param name="string" select="Name" />
                                                </xsl:call-template> (<xsl:value-of select="Role/Role" />)<xsl:value-of select="$tipBreak" />
                                            </xsl:for-each>
                                        </xsl:attribute>
                                        <xsl:call-template name="icon">
                                            <xsl:with-param name="type" select="'more'" />
                                        </xsl:call-template>
                                    </a>
                                </xsl:if>
                                <xsl:if test="Form/Album/ArtistID != 0 and /Root/Access/app/reports/r">
                                    &#160;<a href="/app/reports?c=r&amp;artist={Form/Album/ArtistID}" title="Sales Analytics for &quot;{Form/Album/ArtistName}&quot;" class="js-tooltip">
                                        <xsl:call-template name="icon">
                                            <xsl:with-param name="type" select="'sales-analytics'" />
                                        </xsl:call-template>
                                    </a>
                                </xsl:if>
                            </div>
                        </div>

                        <div class="ValuePair-item">
                            <div class="ValuePair-label">Genre</div>
                            <div class="ValuePair-value">
                                <xsl:value-of select="Form/Album/GenrePrimaryName" />
                            </div>
                        </div>

                        <div class="ValuePair-item">
                            <div class="ValuePair-label">Advisory</div>
                            <div class="ValuePair-value">
                                <xsl:call-template name="albumParentalAdvisory"><xsl:with-param name="advisory" select="Form/Album/AlbumParentalAdvisory" /></xsl:call-template>
                            </div>
                        </div>

                        <xsl:if test="Form/Album/CLine != ''">
                            <div class="ValuePair-item">
                                <div class="ValuePair-label">(C) Line</div>
                                <div class="ValuePair-value">
                                    <xsl:value-of select="Form/Album/CLine" />
                                </div>
                            </div>
                        </xsl:if>

                        <xsl:if test="Form/Album/PLine != ''">
                            <div class="ValuePair-item">
                                <div class="ValuePair-label">(P) Line</div>
                                <div class="ValuePair-value">
                                    <xsl:value-of select="Form/Album/PLine" />
                                </div>
                            </div>
                        </xsl:if>

                        <div class="ValuePair-item">
                            <div class="ValuePair-label">Product Type</div>
                            <div class="ValuePair-value">
                                <xsl:variable name="daCount" select="count(Form/ProductList/Product[ProductTypeID = 3])" />
                                <xsl:if test="$daCount &gt; 0">
                                    DA<xsl:if test="$daCount &gt; 1">(<xsl:value-of select="$daCount" />)</xsl:if>
                                </xsl:if>
                                <xsl:for-each select="Form/ProductList/Product[ProductTypeID != 3]">
                                    <xsl:variable name="productTypeID" select="ProductTypeID" />
                                    <xsl:if test="position() != 1 or $daCount &gt; 0"><xsl:text>, </xsl:text></xsl:if>
                                    <xsl:value-of select="/Root/Form/TypeList/Type[ProductTypeID = $productTypeID]/Description" />
                                </xsl:for-each>
                            </div>
                        </div>

                        <xsl:if test="Form/Album/ClientAlbumID != ''">
                            <div class="ValuePair-item">
                                <div class="ValuePair-label">Client Album ID</div>
                                <div class="ValuePair-value">
                                    <xsl:value-of select="Form/Album/ClientAlbumID" />
                                </div>
                            </div>
                        </xsl:if>

                    </div>
                </div>
                <div class="Album-details-column Album-details-column-fields">

                    <div class="ValuePair-item">
                        <div class="ValuePair-label">Catalog #</div>
                        <div class="ValuePair-value">
                            <xsl:value-of select="Form/Album/CatalogNumber" />
                        </div>
                    </div>

                    <div class="ValuePair-item">
                        <xsl:variable name="labelName" select="Form/LabelList/Label[LabelID = /Root/Form/Album/LabelID]/LabelName" />
                        <div class="ValuePair-label">Label</div>
                        <div class="ValuePair-value">
                            <xsl:value-of select="$labelName" />
                            <xsl:if test="Form/Album/LabelID != 0 and /Root/Access/app/reports/m">
                                &#160;<a href="/app/reports?c=m&amp;label={Form/Album/LabelID}" title="Sales Analytics for &quot;{$labelName}&quot;" class="js-tooltip">
                                    <xsl:call-template name="icon">
                                        <xsl:with-param name="type" select="'sales-analytics'" />
                                    </xsl:call-template>
                                </a>
                            </xsl:if>
                        </div>
                    </div>

                    <div class="ValuePair-item">
                        <div class="ValuePair-label">Album Status</div>
                        <div class="ValuePair-value">
                            <xsl:call-template name="albumStatus"><xsl:with-param name="status" select="Form/Album/Status" /></xsl:call-template>
                        </div>
                    </div>

                    <xsl:choose>
                        <xsl:when test="$isDistClient = 1">
                            <xsl:call-template name="albumDataCell" />
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="custom1Cell" />
                        </xsl:otherwise>
                    </xsl:choose>

                    <xsl:choose>
                        <xsl:when test="$isDistClient = 1">
                            <xsl:call-template name="distReadyCell" />
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="custom2Cell" />
                        </xsl:otherwise>
                    </xsl:choose>

                    <xsl:choose>
                        <xsl:when test="$isDistClient = 1">
                            <xsl:call-template name="custom1Cell" />
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="custom3Cell" />
                        </xsl:otherwise>
                    </xsl:choose>

                    <xsl:if test="$isDistClient = 1">
                        <xsl:call-template name="custom2Cell" />
                    </xsl:if>

                    <xsl:if test="$isDistClient = 1">
                        <xsl:call-template name="custom3Cell" />
                    </xsl:if>

                </div>
            </div>
        </div>
        <div class="Album-last-modified">
            <xsl:call-template name="lastModifiedCell" />
        </div>
    </xsl:template>


    <xsl:template name="lastModifiedCell">
        <p class="HelpText">
            Last Modified: <xsl:value-of select="Form/Album/ModifiedDate" /><xsl:if test="normalize-space(Form/Album/ModifiedBy)"> by <xsl:value-of select="Form/Album/ModifiedBy" /></xsl:if>
        </p>
    </xsl:template>


    <xsl:template name="albumDataCell">
        <div class="ValuePair-item">
            <div class="ValuePair-label">Album Data</div>
            <div class="ValuePair-value">
                <xsl:call-template name="albumDistributionReady"><xsl:with-param name="status" select="Form/Album/IsDistributionReady" /></xsl:call-template>
                <xsl:if test="(not(normalize-space(Form/Album/IsDistributionReady)) or Form/Album/IsDistributionReady != 1) and /Root/Access/rps/catalog/error_report">
                    (<a href="javascript:displayErrorReport();">Show Errors</a>)
                </xsl:if>
                <xsl:call-template name="helpIcon">
                    <xsl:with-param name="tip">Album information (UPC, Title, C-Line, P-Line, etc.), audio files and cover art<xsl:value-of select="$tipBreak" />must all be present and complete before an album can be delivered.<xsl:value-of select="$tipBreak" /><xsl:value-of select="$tipBreak" />The system makes this determination automatically.</xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="salesCell">
        <div class="ValuePair-item">
            <div class="ValuePair-label">Sales</div>
            <div class="ValuePair-value">
                <xsl:choose><xsl:when test="Form/ProductDigital/ProductID and /Root/Access/app/reports/a"><a href="/app/reports?c=a&amp;product={Form/ProductDigital/ProductID}">Digital sales statistics</a></xsl:when><xsl:otherwise>No digital sales</xsl:otherwise></xsl:choose>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="distReadyCell">
        <div class="ValuePair-item">
            <div class="ValuePair-label">Cleared for Distribution</div>
            <div class="ValuePair-value">
                <xsl:choose><xsl:when test="Form/ProductDigital/DistAllow = 1">Yes</xsl:when><xsl:when test="Form/ProductDigital/DistAllow = 0">No</xsl:when><xsl:otherwise>N/A</xsl:otherwise></xsl:choose>
                &#160;<xsl:call-template name="helpIcon">
                <xsl:with-param name="tip">Setting this to "No" will prevent this album from being distributed to any services.<xsl:value-of select="$tipBreak" />Set this field by clicking on "Edit Album."</xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="custom1Cell">
        <xsl:choose>
            <xsl:when test="normalize-space(Form/Album/Custom1)">
                <div class="ValuePair-item">
                    <div class="ValuePair-label">Custom 1</div>
                    <div class="ValuePair-value"><xsl:value-of select="Form/Album/Custom1" /></div>
                </div>
            </xsl:when>
            <xsl:when test="normalize-space(Form/Album/Custom2)">
                <div class="ValuePair-item">
                    <div class="ValuePair-label">Custom 2</div>
                    <div class="ValuePair-value"><xsl:value-of select="Form/Album/Custom2" /></div>
                </div>
            </xsl:when>
            <xsl:when test="normalize-space(Form/Album/Custom3)">
                <div class="ValuePair-item">
                    <div class="ValuePair-label">Custom 3</div>
                    <div class="ValuePair-value"><xsl:value-of select="Form/Album/Custom3" /></div>
                </div>
            </xsl:when>
        </xsl:choose>
    </xsl:template>


    <xsl:template name="custom2Cell">
        <xsl:choose>
            <xsl:when test="normalize-space(Form/Album/Custom1) and normalize-space(Form/Album/Custom2)">
                <div class="ValuePair-item">
                    <div class="ValuePair-label">Custom 2</div>
                    <div class="ValuePair-value"><xsl:value-of select="Form/Album/Custom2" /></div>
                </div>
            </xsl:when>
            <xsl:when test="normalize-space(Form/Album/Custom1) and normalize-space(Form/Album/Custom3)">
                <div class="ValuePair-item">
                    <div class="ValuePair-label">Custom 3</div>
                    <div class="ValuePair-value"><xsl:value-of select="Form/Album/Custom3" /></div>
                </div>
            </xsl:when>
            <xsl:when test="normalize-space(Form/Album/Custom2) and normalize-space(Form/Album/Custom3)">
                <div class="ValuePair-item">
                    <div class="ValuePair-label">Custom 3</div>
                    <div class="ValuePair-value"><xsl:value-of select="Form/Album/Custom3" /></div>
                </div>
            </xsl:when>
        </xsl:choose>
    </xsl:template>


    <xsl:template name="custom3Cell">
        <xsl:if test="normalize-space(Form/Album/Custom1) and normalize-space(Form/Album/Custom2) and normalize-space(Form/Album/Custom3)">
            <div class="ValuePair-item">
                <div class="ValuePair-label">Custom 3</div>
                <div class="ValuePair-value"><xsl:value-of select="Form/Album/Custom3" /></div>
            </div>
        </xsl:if>
    </xsl:template>


    <xsl:template name="trackList">
        <h3>Tracks</h3>
        <table class="Table">
            <xsl:if test="Form/Album/TrackList/Track">
                <thead>
                    <xsl:call-template name="addTrackButton">
                        <xsl:with-param name="position" select="'top'" />
                    </xsl:call-template>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col" id="trackCol">Track</th>
                        <th class="Table-col" id="nameCol">Name</th>
                        <th class="Table-col" id="lengthCol">Length</th>
                        <th class="Table-col" id="artistCol">Artist</th>
                        <th class="Table-col">Parental Advisory</th>
                        <th class="Table-col">Media Type</th>
                        <xsl:if test="Access/rps/track/edit">
                            <th class="Table-col Table-col-icon" id="trackEdit">Actions</th>
                        </xsl:if>
                    </tr>
                </thead>
                <tbody>
                    <xsl:for-each select="Form/Album/TrackList/Track">
                        <xsl:call-template name="trackListRow" />
                    </xsl:for-each>
                </tbody>
            </xsl:if>
            <tfoot>
                <xsl:call-template name="addTrackButton">
                    <xsl:with-param name="position" select="'bottom'" />
                </xsl:call-template>
            </tfoot>
        </table>
    </xsl:template>


    <xsl:template name="addTrackButton">
        <xsl:param name="position" />
        <xsl:if test="Access/rps/track/edit">
            <tr>
                <td colspan="7" class="right">
                    <input type="button" value="Add Track" onClick="javascript:location.href='track?AlbumID={Form/Album/AlbumID}&amp;c=edit'" class="{$position}Button" />
                </td>
            </tr>
        </xsl:if>
    </xsl:template>


    <xsl:template name="trackListRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col">
                <a href="javascript:void(0);" onClick="showDetails(this,'trackDetails{TrackID}');" title="Expand" onMouseOver="javascript:window.status=''; return true;"><img src="/production/images/icons/expand.gif" class="showDetails" /></a>
                <xsl:if test="TrackOrder &lt; 10">0</xsl:if><xsl:value-of select="TrackOrder" />
            </td>
            <td class="Table-col"><a href="track?c=show&amp;TrackID={TrackID}"><xsl:value-of select="Title" /></a></td>
            <td class="Table-col"><xsl:value-of select="Master/Duration" /></td>
            <td class="Table-col"><xsl:value-of select="ArtistName" /></td>
            <td class="Table-col">
                <xsl:call-template name="albumParentalAdvisory">
                    <xsl:with-param name="advisory" select="ParentalAdvisory" />
                </xsl:call-template>
            </td>
            <td class="Table-col">
                <xsl:choose>
                    <xsl:when test="MediaType = 2">Video</xsl:when>
                    <xsl:otherwise>Audio</xsl:otherwise>
                </xsl:choose>
            </td>
            <xsl:if test="/Root/Access/rps/track/edit">
                <td class="Table-col Table-col-icon">
                    <xsl:call-template name="uiEditTrigger">
                        <xsl:with-param name="url">
                            <xsl:text>/rps/track?c=edit&amp;TrackID=</xsl:text>
                            <xsl:value-of select="TrackID" />
                        </xsl:with-param>
                    </xsl:call-template>
                </td>
            </xsl:if>
        </tr>
        <tr class="trackInfo Table-row Table-row-sub" id="trackDetails{TrackID}" style="display:none">
            <td class="Table-col" colspan="3">
                <table class="Table Table-light">
                    <thead>
                        <tr class="Table-row Table-row-header">
                            <th colspan="2" class="Table-col">Master</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">Title:</td>
                            <td class="Table-col"><xsl:value-of select="Master/Title" /></td>
                        </tr>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">Artist:</td>
                            <td class="Table-col"><xsl:value-of select="Master/ArtistName" /></td>
                        </tr>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">ISRC:</td>
                            <td class="Table-col"><xsl:value-of select="Master/ISRC" /></td>
                        </tr>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">Recording Date:</td>
                            <td class="Table-col"><xsl:value-of select="Master/DateRecorded" /></td>
                        </tr>
                    </tbody>
                </table>
            </td>
            <td colspan="3" class="Table-col">
                <xsl:if test="/Root/Access/rps/track/edit">
                    <xsl:attribute name="colspan">4</xsl:attribute>
                </xsl:if>
                <table class="Table">
                    <thead>
                        <tr class="Table-row Table-row-header">
                            <th colspan="2" class="Table-col">Song</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">Title:</td>
                            <td class="Table-col"><xsl:value-of select="Master/Song/Title" /></td>
                        </tr>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">Composer:</td>
                            <td class="Table-col"><xsl:value-of select="Master/Song/ComposerName" /></td>
                        </tr>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col">ISWC:</td>
                            <td class="Table-col"><xsl:value-of select="Master/Song/ISWC" /></td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </xsl:template>


    <xsl:template name="productView">
        <h3>Products</h3>
        <table class="Table">
            <xsl:if test="Form/ProductList/Product">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col" id="productType">Type</th>
                        <th class="Table-col" id="productID">Product ID</th>
                        <th class="Table-col" id="productUPC">UPC</th>
                        <th class="Table-col" id="productDate">Release Date</th>
                        <th class="Table-col" id="productStatus">Status</th>
                        <th class="Table-col Table-col-all-actions">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <xsl:for-each select="Form/ProductList/Product">
                        <xsl:call-template name="productRow" />
                    </xsl:for-each>
                </tbody>
            </xsl:if>
            <tfoot>
                <tr class="Table-row Table-row-data">
                    <td class="Table-col" colspan="7">
                        <input type="button" id="addProductButton" value="Add Product" onClick="location.href='product?c=edit&amp;AlbumID={Form/Album/AlbumID}'" class="bottomButton">
                            <xsl:if test="not(Form/Album/TrackList/Track/TrackID) or count(Form/TypeList/Type) = count(Form/ProductList/Product)">
                                <xsl:attribute name="disabled">disabled</xsl:attribute>
                            </xsl:if>
                        </input>
                    </td>
                </tr>
            </tfoot>
        </table>
    </xsl:template>


    <xsl:template name="productRow">
        <tr class="Table-row Table-row-data">
            <xsl:variable name="productTypeID" select="ProductTypeID" />
            <td class="Table-col">
                <a href="/rps/product?c=show&amp;ProductID={ProductID}">
                    <xsl:value-of select="/Root/Form/TypeList/Type[ProductTypeID = $productTypeID]/Description" />
                </a>
            </td>
            <td class="Table-col"><xsl:value-of select="ProductCode" /></td>
            <td class="Table-col"><xsl:value-of select="UPC" /></td>
            <td class="Table-col"><xsl:value-of select="ReleaseDate" /></td>
            <xsl:variable name="productPriceID" select="ProductPriceID" />
            <xsl:variable name="productStatusID" select="ProductStatusID" />
            <td class="Table-col"><xsl:value-of select="/Root/Form/StatusList/Status[ProductStatusID = $productStatusID]/Description" /></td>
            <td class="Table-col Table-col-icon">
                <a href="/rps/product?c=edit&amp;ProductID={ProductID}">Edit</a>
            </td>
        </tr>
    </xsl:template>


</xsl:stylesheet>
