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

    <xsl:template name="catalogEditLayout">
        <div class="CatalogEdit" id="catalogEdit">

            <form action="/rps/catalog" name="catalogEntry" id="catalogEntry" method="post">
                <xsl:call-template name="openRunStatusMessage" />
                <xsl:call-template name="errorMessageGeneral" />

                <div class="Form-header">
                    <div class="Form-header-wrapper Form-header-wrapper-text">
                        <p class="Form-header-text">Enter album information here.</p>
                    </div>
                    <div class="Form-header-wrapper Form-header-wrapper-required">
                        <span class="Form-header-required-note">
                            * Required field
                        </span>
                    </div>
                </div>

                <div class="CatalogEdit-forms">
                    <div class="CatalogEdit-album-wrapper">
                            <input type="hidden" name="formSubmit" value="1" />
                            <input type="hidden" name="c" value="edit" />
                            <xsl:if test="Params/show_errors">
                                <input type="hidden" name="show_errors" value="1" />
                            </xsl:if>
                            <xsl:call-template name="albumEdit" />
                    </div>
                </div>
                <xsl:call-template name="buttons" />
            </form>
        </div>
    </xsl:template>

    <xsl:template name="albumEdit">
        <xsl:if test="normalize-space(Form/Album/AlbumID)">
            <input type="hidden" name="AlbumID" value="{Form/Album/AlbumID}" />
        </xsl:if>
            <xsl:if test="Form/Album/AlbumID = ''">
            <input type="hidden" name="new" value="1" />
        </xsl:if>

        <div id="roleSelectTemplate" style="display:none">
            <xsl:call-template name="additionalArtistRoleSelect" />
        </div>

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

    <xsl:template name="albumEditFields">
        <fieldset class="Form-fieldset Form-fieldset-standart">
            <xsl:call-template name="catalogNumberRow" />
            <xsl:call-template name="catalogTitleRow" />
            <xsl:call-template name="catalogTitleVersionRow" />
            <xsl:call-template name="catalogArtistRow" />
        </fieldset>
        <fieldset class="Form-fieldset Form-fieldset-standart AdditionalGroup" id="albumTable">
            <xsl:call-template name="catalogAdditionalArtistRow" />
        </fieldset>
        <fieldset class="Form-fieldset Form-fieldset-standart">
            <xsl:call-template name="catalogLabelRow" />
            <xsl:call-template name="catalogCLineRow" />
            <xsl:call-template name="catalogPLineRow" />
            <xsl:call-template name="catalogGenrePrimaryRow" />
            <xsl:call-template name="catalogGenreSecondaryRow" />
            <xsl:call-template name="catalogClearedForDistributionRow" />
            <xsl:call-template name="catalogStatusRow" />
            <xsl:call-template name="catalogClientAlbumIDRow" />
            <xsl:call-template name="catalogCustom1Row" />
            <xsl:call-template name="catalogCustom2Row" />
            <xsl:call-template name="catalogCustom3Row" />

            <xsl:if test="ClientTypes/ClientType[ClientTypeID = 2]/IsClientTypeFlag != 1 and ClientTypes/ClientType[ClientTypeID = 5]/IsClientTypeFlag != 1 and ClientTypes/ClientType[ClientTypeID = 6]/IsClientTypeFlag != 1">
                <xsl:call-template name="catalogUPCRow" />
                <xsl:call-template name="catalogReleaseDateRow" />
            </xsl:if>
        </fieldset>
    </xsl:template>

    <xsl:template name="catalogNumberRow">
        <div class="Form-item Form-item-required">

            <xsl:if test="Form/Album/CatalogNumber[@e]">
                <xsl:attribute name="class">
                    <xsl:text>Form-item Form-item-required Form-item-error</xsl:text>
                </xsl:attribute>
            </xsl:if>

            <label class="Form-label">
                <span class="Form-label-caption">Catalog #</span>
                <div class="Form-input-wrapper">
                    <input type="text" name="Form_Album_CatalogNumber" id="Form_Album_CatalogNumber" maxlength="20" value="{Form/Album/CatalogNumber}" class="Input Form-input">
                      <xsl:if test="$openRuns = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                      </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/CatalogNumber</xsl:with-param>
                <xsl:with-param name="displayName">Catalog #</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogTitleRow">
        <div class="Form-item Form-item-required">
            <xsl:if test="Form/Album/Title[@e]">
                <xsl:attribute name="class">
                    <xsl:text>Form-item Form-item-required Form-item-error</xsl:text>
                </xsl:attribute>
            </xsl:if>

            <label class="Form-label">
                <span class="Form-label-caption">Title</span>
                <div class="Form-input-wrapper">
                    <input type="text" class="Input Form-input" name="Form_Album_Title" id="Form_Album_Title" value="{Form/Album/Title}" >
                      <xsl:if test="$openRuns = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                      </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/Title</xsl:with-param>
                <xsl:with-param name="displayName">Title</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogTitleVersionRow">
        <div class="Form-item">
            <xsl:if test="Form/Album/TitleVersion[@e]">
                <xsl:attribute name="class">
                    <xsl:text>Form-item Form-item-error</xsl:text>
                </xsl:attribute>
            </xsl:if>
            <label class="Form-label">
                <span class="Form-label-caption">Title Version</span>
                <div class="Form-input-wrapper">
                    <input type="text" name="Form_Album_TitleVersion" id="Form_Album_TitleVersion" maxlength="50" value="{Form/Album/TitleVersion}" class="Input Form-input">
                      <xsl:if test="$openRuns = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                      </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/TitleVersion</xsl:with-param>
                <xsl:with-param name="displayName">Title Version</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogArtistRow">
        <div class="Form-item Form-item-required">
            <xsl:if test="Form/Album/ArtistName[@e]">
                <xsl:attribute name="class">
                    <xsl:text>Form-item Form-item-required Form-item-error</xsl:text>
                </xsl:attribute>
            </xsl:if>
            <label class="Form-label">
                <span class="Form-label-caption">Primary Artist</span>
                <div id="myAutoComplete" class="Form-input-wrapper">
                    <input id="Form_Album_ArtistName" name="Form_Album_ArtistName" type="text" class="Input Form-input" value="{Form/Album/ArtistName}" >
                      <xsl:if test="$openRuns = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                      </xsl:if>
                    </input>
                    <span id="noMatchWarning" class="yui-ac-warning"></span>
                    <input type="hidden" name="Form_Album_ArtistID" id="Form_Album_ArtistID" value="{Form/Album/ArtistID}" />
                    <script type="text/javascript">
                        new rsAutoCompleteNew({
                            url: "/rps/catalog?c=search_artist&amp;limit=10",
                            targetInputName: "Form_Album_ArtistName",
                            targetInputID: "Form_Album_ArtistID",
                            noMatchItem: "noMatchWarning",
                            noMatchText: "(New)",
                            blockName: "Artist",
                            itemName: "Name",
                            itemID: "ArtistID",
                        }).init();
                    </script>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/ArtistName</xsl:with-param>
                <xsl:with-param name="displayName">Artist</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogAdditionalArtistRow">

        <xsl:for-each select="Form/Album/AdditionalArtistList/AdditionalArtist">
            <xsl:sort select="New" />
            <xsl:sort select="AdditionalArtistID" data-type="number" />
            <xsl:sort select="OriginalKey" />

            <xsl:call-template name="catalogAdditionalArtistRowWithKey" >
                <xsl:with-param name="key">
                    <xsl:choose>
                        <xsl:when test="normalize-space(OriginalKey)"><xsl:value-of select="OriginalKey" /></xsl:when>
                        <xsl:otherwise><xsl:value-of select="/Root/Form/Album/AlbumID" />.<xsl:value-of select="ArtistID" />.<xsl:value-of select="Role/ArtistRoleID" /></xsl:otherwise>
                    </xsl:choose>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:for-each>

        <div id="addLinkRow" class="Form-item">
            <xsl:if test="$openRuns = 0">
                <xsl:call-template name="uiButton">
                    <xsl:with-param name="type" select="'text-inline'" />
                    <xsl:with-param name="id" select="'catalog-add-additional-artist'" />
                    <xsl:with-param name="className" select="'js-catalog-add-artist'" />
                    <xsl:with-param name="iconLeftType" select="'add'" />
                    <xsl:with-param name="content" select="'Add Another Artist'" />
                </xsl:call-template>
            </xsl:if>
        </div>

    </xsl:template>

    <xsl:template name="catalogAdditionalArtistRowWithKey">
        <xsl:param name="key" />
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-group-vertical Form-group-with-control js-additional-artist-group AdditionalGroup-item</xsl:text>
                <xsl:if test="normalize-space(Delete)">
                    <xsl:text> AnimateReveal AnimateReveal-hidden</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <div class="Form-group-inputs-container">
                <div class="Form-item" id="myAutoComplete_{$key}">

                    <xsl:if test="Name[@e]">
                        <xsl:attribute name="class">
                            <xsl:text>Form-item Form-item-error</xsl:text>
                        </xsl:attribute>
                    </xsl:if>

                    <label class="Form-label">
                        <span class="Form-label-caption">Additional Artist</span>
                        <div id="myAutoComplete" class="Form-input-wrapper">
                            <input
                                id="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_Name"
                                name="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_Name"
                                type="text"
                                class="Input Form-input"
                                value="{Name}"
                            >
                                <xsl:if test="$openRuns = 1">
                                    <xsl:attribute name="disabled">disabled</xsl:attribute>
                                </xsl:if>
                            </input>
                            <span id="noMatchWarning_{$key}" class="yui-ac-warning"></span>

                            <input type="hidden" name="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_ArtistID" id="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_ArtistID" value="{ArtistID}" />
                            <input type="hidden" name="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_AlbumID" id="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_AlbumID" value="{/Root/Form/Album/AlbumID}" />
                            <input type="hidden" name="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_OriginalKey" id="Form_Album_AdditionalArtistList_AdditionalArtist_{$key}_OriginalKey" value="{$key}" />

                            <script type="text/javascript">
                                new rsAutoCompleteNew({
                                    url: "/rps/catalog?c=search_artist&amp;limit=10",
                                    targetInputName: "Form_Album_AdditionalArtistList_AdditionalArtist_<xsl:value-of select="$key"/>_Name",
                                    targetInputID: "Form_Album_AdditionalArtistList_AdditionalArtist_<xsl:value-of select="$key"/>_ArtistID",
                                    noMatchItem: "noMatchWarning_<xsl:value-of select="$key"/>",
                                    noMatchText: "(New)",
                                    blockName: "Artist",
                                    itemName: "Name",
                                    itemID: "ArtistID",
                                }).init();
                            </script>
                        </div>
                    </label>
                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Name</xsl:with-param>
                        <xsl:with-param name="displayName">Artist</xsl:with-param>
                    </xsl:call-template>
                </div>

                <div class="Form-item" id="myAutoComplete_{$key}">

                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="ArtistRoleID[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>
                    </xsl:attribute>

                    <label class="Form-label">
                        <span class="Form-label-caption">Role</span>
                        <div class="Form-input-wrapper">
                            <xsl:call-template name="additionalArtistRoleSelect" >
                                <xsl:with-param name="formIndex"><xsl:value-of select="$key" /></xsl:with-param>
                                <xsl:with-param name="selectedID"><xsl:value-of select="Role/ArtistRoleID" /></xsl:with-param>
                            </xsl:call-template>
                        </div>
                    </label>
                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">ArtistRoleID</xsl:with-param>
                        <xsl:with-param name="displayName">Role</xsl:with-param>
                    </xsl:call-template>
                </div>
            </div>

            <div class="Form-group-control-container">
                <span class="Form-group-control Icon-trigger">
                    <xsl:if test="$openRuns = 0">
                        <xsl:call-template name="icon">
                            <xsl:with-param name="type" select="'delete'" />
                            <xsl:with-param name="role" select="'action'" />
                        </xsl:call-template>
                    </xsl:if>
                    <input type="hidden" class="Form-group-is-deleted">
                        <xsl:attribute name="name">
                            <xsl:text>Form_Album_AdditionalArtistList_AdditionalArtist_</xsl:text>
                            <xsl:value-of select="$key" />
                            <xsl:text>_Delete</xsl:text>
                        </xsl:attribute>
                        <xsl:attribute name="value">
                            <xsl:if test="normalize-space(Delete)">
                                <xsl:text>1</xsl:text>
                            </xsl:if>
                        </xsl:attribute>
                    </input>
                </span>
            </div>

        </div>

    </xsl:template>

    <xsl:template name="additionalArtistRoleSelect" >
        <xsl:param name="formIndex" />
        <xsl:param name="selectedID" />

        <xsl:variable name="additionalArtistRoles">
            <map>
                <mapEntry><name>Choose...</name><value>0</value></mapEntry>
                <xsl:for-each select="/Root/Form/ArtistRoleList/ArtistRole" >
                    <mapEntry><name><xsl:value-of select="Role" /></name><value><xsl:value-of select="ArtistRoleID"/></value></mapEntry>
                </xsl:for-each>
            </map>
        </xsl:variable>

        <xsl:call-template name="uiDropdown">
            <xsl:with-param name="items" select="$additionalArtistRoles"/>
            <xsl:with-param name="active" select="$selectedID" />
            <xsl:with-param name="disabled">
                <xsl:if test="$openRuns = 1">
                    <xsl:text>true</xsl:text>
                </xsl:if>
            </xsl:with-param>
            <xsl:with-param name="id">additionalArtistRoleSelect_<xsl:value-of select="$formIndex" /></xsl:with-param>
            <xsl:with-param name="name">
                <xsl:if test="normalize-space($formIndex)" >
                   <xsl:text>Form_Album_AdditionalArtistList_AdditionalArtist_</xsl:text><xsl:value-of select="$formIndex" /><xsl:text>_ArtistRoleID</xsl:text>
                </xsl:if>
                <xsl:if test="not(normalize-space($formIndex))" >
                    <xsl:text>temp_ArtistRoleID</xsl:text>
                </xsl:if>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="catalogLabelRow">
        <xsl:choose>
            <xsl:when test="Form/LabelList/Label">
                <script type="text/javascript">
                requireField("Form_Album_LabelID","Label must be selected.<br />");
                </script>

                <div class="Form-item Form-item-required">
                    <xsl:if test="Form/Album/LabelID[@e]">
                        <xsl:attribute name="class">
                            <xsl:text>Form-item Form-item-required Form-item-error</xsl:text>
                        </xsl:attribute>
                    </xsl:if>

                    <label class="Form-label">
                        <span class="Form-label-caption">Label</span>
                        <div class="Form-input-wrapper">
                            <xsl:variable name="addAlbumLabels">
                                <map>
                                    <mapEntry><name>Choose...</name><value></value></mapEntry>
                                    <xsl:for-each select="Form/LabelList/Label">
                                        <mapEntry><name><xsl:value-of select="LabelName" /></name><value><xsl:value-of select="LabelID"/></value></mapEntry>
                                    </xsl:for-each>
                                </map>
                            </xsl:variable>

                            <xsl:call-template name="uiDropdown">
                                <xsl:with-param name="items" select="$addAlbumLabels"/>
                                <xsl:with-param name="active" select="/Root/Form/Album/LabelID" />
                                <xsl:with-param name="disabled">
                                    <xsl:if test="$openRuns = 1">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </xsl:with-param>
                                <xsl:with-param name="id" select="'Form_Album_LabelID'"/>
                                <xsl:with-param name="name" select="'Form_Album_LabelID'" />
                            </xsl:call-template>
                        </div>
                    </label>
                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Form/Album/LabelID</xsl:with-param>
                        <xsl:with-param name="displayName">Label</xsl:with-param>
                    </xsl:call-template>
                </div>

            </xsl:when>
            <xsl:otherwise>
                <input type="hidden" name="Form_Album_LabelID" value="{Form/Album/LabelID}" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="catalogStatusRow">
        <div class="Form-item">
            <label class="Form-label">
                <span class="Form-label-caption">Status</span>
                <div class="Form-input-wrapper">
                    <xsl:variable name="addAlbumStatuses">
                        <map>
                            <mapEntry><name>Active</name><value>1</value></mapEntry>
                            <mapEntry><name>Inactive</name><value>0</value></mapEntry>
                        </map>
                    </xsl:variable>

                    <xsl:call-template name="uiDropdown">
                        <xsl:with-param name="items" select="$addAlbumStatuses"/>
                        <xsl:with-param name="active" select="Form/Album/Status" />
                        <xsl:with-param name="disabled">
                            <xsl:if test="$openRuns = 1">
                                <xsl:text>true</xsl:text>
                            </xsl:if>
                        </xsl:with-param>
                        <xsl:with-param name="id" select="'Form_Album_Status'"/>
                        <xsl:with-param name="name" select="'Form_Album_Status'" />
                    </xsl:call-template>
                </div>
            </label>
        </div>
    </xsl:template>

    <xsl:template name="catalogCLineRow">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/Album/CLine[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">
                    (C) Line
                    <xsl:call-template name="helpIcon">
                        <xsl:with-param name="tip">The Copyright Line is a four-digit year followed<xsl:value-of select="$tipBreak" />by a space and the copyright holder's name.</xsl:with-param>
                    </xsl:call-template>
                </span>
                <div class="Form-input-wrapper">
                    <input type="text" name="Form_Album_CLine" id="Form_Album_CLine" maxlength="50" value="{Form/Album/CLine}" class="Form-input Input">
                      <xsl:if test="$openRuns = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                      </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/CLine</xsl:with-param>
                <xsl:with-param name="displayName">(C) Line</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogPLineRow">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/Album/PLine[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">
                    (P) Line
                    <xsl:call-template name="helpIcon">
                        <xsl:with-param name="tip">The Phonogram Copyright Line is a four-digit year followed<xsl:value-of select="$tipBreak" />by a space and the phonogram copyright holder's name.</xsl:with-param>
                    </xsl:call-template>
                </span>
                <div class="Form-input-wrapper">
                    <input class="Input Form-input" type="text" name="Form_Album_PLine" id="Form_Album_PLine" maxlength="50" value="{Form/Album/PLine}" >
                      <xsl:if test="$openRuns = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                      </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/PLine</xsl:with-param>
                <xsl:with-param name="displayName">(P) Line</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogGenrePrimaryRow">
        <xsl:choose>
            <xsl:when test="Form/GenreList/Genre">
                <div>
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="Form/Album/GenrePrimaryID[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>
                    </xsl:attribute>

                    <label class="Form-label">
                        <span class="Form-label-caption">Primary Genre</span>
                        <div class="Form-input-wrapper">

                            <xsl:variable name="addAlbumPrimaryGenre">
                                <map>
                                    <mapEntry><name>Choose...</name><value></value></mapEntry>
                                    <xsl:for-each select="Form/GenreList/Genre">
                                        <mapEntry><name><xsl:value-of select="GenreName" /></name><value><xsl:value-of select="GenreID"/></value></mapEntry>
                                    </xsl:for-each>
                                </map>
                            </xsl:variable>

                            <xsl:call-template name="uiDropdown">
                                <xsl:with-param name="items" select="$addAlbumPrimaryGenre"/>
                                <xsl:with-param name="active" select="/Root/Form/Album/GenrePrimaryID" />
                                <xsl:with-param name="disabled">
                                    <xsl:if test="$openRuns = 1">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </xsl:with-param>
                                <xsl:with-param name="id" select="'Form_Album_GenrePrimaryID'"/>
                                <xsl:with-param name="name" select="'Form_Album_GenrePrimaryID'" />
                            </xsl:call-template>

                        </div>
                    </label>
                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Form/Album/GenrePrimaryID</xsl:with-param>
                        <xsl:with-param name="displayName">Primary Genre</xsl:with-param>
                    </xsl:call-template>
                </div>
            </xsl:when>
            <xsl:otherwise>
                <input type="hidden" name="Form_Album_GenrePrimaryID" value="{Form/Album/GenrePrimaryID}" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="catalogGenreSecondaryRow">
        <xsl:choose>
            <xsl:when test="Form/GenreList/Genre">
                <div>
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="Form/Album/GenreSecondaryID[@e]">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>
                    </xsl:attribute>

                    <label class="Form-label">
                        <span class="Form-label-caption">Secondary Genre</span>
                        <div class="Form-input-wrapper">

                            <xsl:variable name="addAlbumPrimaryGenre">
                                <map>
                                    <mapEntry><name>Choose...</name><value></value></mapEntry>
                                    <xsl:for-each select="Form/GenreList/Genre">
                                        <mapEntry><name><xsl:value-of select="GenreName" /></name><value><xsl:value-of select="GenreID"/></value></mapEntry>
                                    </xsl:for-each>
                                </map>
                            </xsl:variable>

                            <xsl:call-template name="uiDropdown">
                                <xsl:with-param name="items" select="$addAlbumPrimaryGenre"/>
                                <xsl:with-param name="active" select="/Root/Form/Album/GenreSecondaryID" />
                                <xsl:with-param name="disabled">
                                    <xsl:if test="$openRuns = 1">
                                        <xsl:text>true</xsl:text>
                                    </xsl:if>
                                </xsl:with-param>
                                <xsl:with-param name="id" select="'Form_Album_GenreSecondaryID'"/>
                                <xsl:with-param name="name" select="'Form_Album_GenreSecondaryID'" />
                            </xsl:call-template>

                        </div>
                    </label>
                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Form/Album/GenreSecondaryID</xsl:with-param>
                        <xsl:with-param name="displayName">Secondary Genre</xsl:with-param>
                    </xsl:call-template>
                </div>
            </xsl:when>
            <xsl:otherwise>
                <input type="hidden" name="Form_Album_GenreSecondaryID" value="{Form/Album/GenreSecondaryID}" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="catalogClearedForDistributionRow">
        <xsl:if test="$isDistClient = 1">
            <div>
                <xsl:attribute name="class">
                    <xsl:text>Form-item</xsl:text>
                    <xsl:if test="Form/ProductDigital/DistAllow[@e]">
                        <xsl:text> Form-item-error</xsl:text>
                    </xsl:if>
                </xsl:attribute>

                <label class="Form-label">
                    <span class="Form-label-caption">Cleared For Distribution</span>
                    <div class="Form-input-wrapper">

                        <xsl:variable name="addAlbumDistAllow">
                            <map>
                                <mapEntry><name>Yes</name><value>1</value></mapEntry>
                                <mapEntry><name>No</name><value>0</value></mapEntry>
                            </map>
                        </xsl:variable>

                        <xsl:call-template name="uiDropdown">
                            <xsl:with-param name="items" select="$addAlbumDistAllow"/>
                            <xsl:with-param name="active" select="Form/ProductDigital/DistAllow" />
                            <xsl:with-param name="disabled">
                                <xsl:if test="$openRuns = 1">
                                    <xsl:text>true</xsl:text>
                                </xsl:if>
                            </xsl:with-param>
                            <xsl:with-param name="id" select="'Form_ProductDigital_DistAllow'"/>
                            <xsl:with-param name="name" select="'Form_ProductDigital_DistAllow'" />
                        </xsl:call-template>

                    </div>
                </label>
                <xsl:call-template name="inlineError">
                    <xsl:with-param name="path">Form/ProductDigital/DistAllow</xsl:with-param>
                    <xsl:with-param name="displayName">Distribution Allowed</xsl:with-param>
                </xsl:call-template>
            </div>
        </xsl:if>
    </xsl:template>

    <xsl:template name="catalogClientAlbumIDRow">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/Album/ClientAlbumID[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">Client Album ID</span>
                <div class="Form-input-wrapper">
                    <input class="Input Form-input" type="text" name="Form_Album_ClientAlbumID" id="Form_Album_ClientAlbumID" maxlength="50" value="{Form/Album/ClientAlbumID}" >
                        <xsl:if test="$openRuns = 1">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/ClientAlbumID</xsl:with-param>
                <xsl:with-param name="displayName">Client Album ID</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogCustom1Row">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/Album/Custom1[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">Custom 1</span>
                <div class="Form-input-wrapper">
                    <input class="Input Form-input" type="text" name="Form_Album_Custom1" id="Form_Album_Custom1" maxlength="50" value="{Form/Album/Custom1}" >
                        <xsl:if test="$openRuns = 1">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/Custom1</xsl:with-param>
                <xsl:with-param name="displayName">Custom 1</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogCustom2Row">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/Album/Custom2[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">Custom 2</span>
                <div class="Form-input-wrapper">
                    <input class="Input Form-input" type="text" name="Form_Album_Custom2" id="Form_Album_Custom2" maxlength="50" value="{Form/Album/Custom2}" >
                        <xsl:if test="$openRuns = 1">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/Custom2</xsl:with-param>
                <xsl:with-param name="displayName">Custom 2</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogCustom3Row">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/Album/Custom3[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">Custom 3</span>
                <div class="Form-input-wrapper">
                    <input class="Input Form-input" type="text" name="Form_Album_Custom3" id="Form_Album_Custom3" maxlength="50" value="{Form/Album/Custom3}" >
                        <xsl:if test="$openRuns = 1">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Album/Custom3</xsl:with-param>
                <xsl:with-param name="displayName">Custom 3</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogUPCRow">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/Product/UPC[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">Digital UPC</span>
                <div class="Form-input-wrapper">
                    <input class="Input Form-input" type="text" name="Form_Product_UPC" id="Form_Product_UPC" value="{Form/Product/UPC}" >
                        <xsl:if test="$openRuns = 1">
                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                        </xsl:if>
                    </input>
                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Product/UPC</xsl:with-param>
                <xsl:with-param name="displayName">UPC</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="catalogReleaseDateRow">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/Product/ReleaseDate[@e]">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <label class="Form-label">
                <span class="Form-label-caption">Release Date</span>
                <div class="Form-input-wrapper">

                <xsl:call-template name="uiDatepicker">
                    <xsl:with-param name="id" select="'Form_Product_ReleaseDate'" />
                    <xsl:with-param name="name" select="'Form_Product_ReleaseDate'" />
                    <xsl:with-param name="value">
                        <xsl:choose>
                            <xsl:when test="normalize-space(Form/Product/ReleaseDate)">
                                <xsl:value-of select="Form/Product/ReleaseDate" />
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="Form/TodaysDate" />
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>

                    <xsl:with-param name="className" select="'LicenseIncome-table-input'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="$openRuns = 1">
                            <xsl:text name="disabled">true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>

                </div>
            </label>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/Product/ReleaseDate</xsl:with-param>
                <xsl:with-param name="displayName">Release Date</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

</xsl:stylesheet>
