<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--                                                                  -->
<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:output method="html" indent="no" doctype-system="" encoding="utf-8" />

    <xsl:include href="/app/tools/rps/templates/global.xsl" />
    <xsl:include href="shared.xsl" />


    <xsl:variable name="lockedRecord">
        <xsl:choose>
            <xsl:when test="$cmd != 'copy' and /Root/Form/TrackLicense/Status = 2">1</xsl:when>
            <xsl:when test="$openRuns &gt; 0">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>


    <xsl:template name="pickLayout">
        <div class="MainBaseSection">
            <xsl:call-template name="licenseValidation" />
            <form name="licenseEdit" id="licenseEdit" method="post" action="{$area}">
                <input type="hidden" name="formSubmit" value="1" />
                <input type="hidden" name="c" value="{$cmd}" />
                <input type="hidden" name="Form_TrackLicense_Type" value="{Form/TrackLicense/Type}" />
                <input type="hidden" name="LicenseType" value="{Form/TrackLicense/Type}" />

                <xsl:if test="Params/ReturnTo">
                    <input type="hidden" name="ReturnTo" value="{Params/ReturnTo}" />
                </xsl:if>
                <xsl:if test="Params/TrackID and $cmd != 'copy'">
                    <input type="hidden" name="TrackID" value="{Params/TrackID}" />
                </xsl:if>
                <xsl:if test="normalize-space(Form/TrackLicense/TrackLicenseID) and $cmd != 'copy'">
                    <input type="hidden" name="TrackLicenseID" value="{Form/TrackLicense/TrackLicenseID}" />
                </xsl:if>

                <div class="LicenseEdit">
                    <xsl:call-template name="openRunStatusMessage" />
                    <xsl:call-template name="helpLink">
                        <xsl:with-param name="extraParams">&amp;licenseType=<xsl:value-of select="$licenseType" /></xsl:with-param>
                    </xsl:call-template>
                    <xsl:if test="$cmd = 'edit'">
                        <div class="Required-notice-wrapper">
                            <xsl:call-template name="trackView">
                                <xsl:with-param name="track" select="Form/Track" />
                                <xsl:with-param name="albumTitle" select="Form/Track/AlbumName" />
                            </xsl:call-template>
                            <div class="Required-notice" />
                        </div>
                    </xsl:if>
                    <xsl:if test="$cmd = 'copy'">
                        <script type="text/javascript">
                            requireField("TrackID","At least one track  must be selected.<br />");
                        </script>
                        <xsl:if test="$licenseType = 'ccomp'">
                            <input type="hidden" name="ControlledCompositionID" value="{Form/TrackLicense/ControlledCompositionID}" />
                        </xsl:if>

                        <input type="hidden" name="TrackLicenseID" value="{Params/TrackLicenseID}" />

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

                        <xsl:if test="count(//@e) = 1">
                            <span class="error">License could not be copied to selected track(s).</span>
                        </xsl:if>

                        <xsl:call-template name="licenseCopyTracks" />
                    </xsl:if>
                    <xsl:call-template name="trackLicenseSection" />
                </div>
                <xsl:call-template name="buttons" />
            </form>
        </div>
    </xsl:template>


    <xsl:template name="licenseValidation">
        <xsl:choose>
            <xsl:when test="$licenseType = 'ccomp'">
                <script type="text/javascript" src="/production/javascript/validateControlledComp.js?v=2"></script>
            </xsl:when>
            <xsl:when test="$licenseType = 'public'">
                <script type="text/javascript" src="/production/javascript/validatePublicDomain.js?v=2"></script>
            </xsl:when>
            <xsl:otherwise>
                <script type="text/javascript" src="/production/javascript/validateLicense.js?v=3"></script>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template name="trackLicenseSection">
        <xsl:choose>
            <xsl:when test="$licenseType = 'ccomp'">
                <xsl:if test="normalize-space(Params/ControlledCompositionID)">
                    <input type="hidden" name="ControlledCompositionID" value="{Params/ControlledCompositionID}" />
                    <input type="hidden" name="Form_TrackLicense_ControlledCompositionID" value="{Params/ControlledCompositionID}" />
                </xsl:if>
            </xsl:when>
        </xsl:choose>

        <section class="LicenseEdit-section">
            <h2><xsl:value-of select="$licenseUpper" /></h2>
            <div class="Form-header">
                <xsl:call-template name="licenseInstructions" />
            </div>
            <xsl:if test="$cmd != 'copy'">
                <xsl:call-template name="errorMessageGeneral" />
            </xsl:if>
            <xsl:if test="$licenseType = 'ccomp' and Form/TrackLicense/NoValidRegion">
                <p class="errorGeneral messageBox">
                    A US-only Region is needed for this license.
                </p>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="$licenseType = 'public'">
                    <xsl:call-template name="publicFields" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="licenseFields" />
                </xsl:otherwise>
            </xsl:choose>
        </section>
    </xsl:template>


    <xsl:template name="licenseInstructions">
        <xsl:choose>
            <xsl:when test="$cmd = 'copy'">
                Editing the <xsl:value-of select="$licenseLower" /> on this page will not affect the original <xsl:value-of select="$licenseLower" />.
            </xsl:when>
            <xsl:otherwise>
                <xsl:if test="Form/TrackLicense/Status = 1 or Form/TrackLicense/Status = 3">
                    Edit <xsl:value-of select="$licenseLower" /> information here.
                </xsl:if>
                <xsl:if test="Form/TrackLicense/Status = ''">
                    Enter <xsl:value-of select="$licenseLower" /> information here.
                </xsl:if>
                <xsl:if test="Form/TrackLicense/Status = 2">
                    This <xsl:value-of select="$licenseLower" /> is used in a pending statement and may not be edited at this time.
                </xsl:if>
                <xsl:if test="Form/TrackLicense/ParentTrackLicenseID &gt; 0">
                    (This <xsl:value-of select="$licenseLower" /> is an updated version of a <a href="/rps/license?c=show&amp;TrackLicenseID={Form/TrackLicense/ParentTrackLicenseID}">previous <xsl:value-of select="$licenseLower" /></a>.)
                </xsl:if>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="ownershipSection">
        <fieldset class="Form-fieldset LicenseEdit-fieldset">
            <h3>Ownership</h3>
            <div class="InformationCols">
                <div class="InformationCols-item">

                    <xsl:if test="$licenseType = 'license'">
                        <xsl:call-template name="productTypeField" />
                    </xsl:if>

                    <xsl:if test="$licenseType = 'ringtone'">
                        <xsl:call-template name="ringtoneField" />
                    </xsl:if>

                    <xsl:call-template name="regionField" />
                    <xsl:call-template name="shareField" />
                    <xsl:call-template name="payorField" />
                    <xsl:call-template name="publisherField" />
                    <xsl:call-template name="adminField" />
                    <xsl:call-template name="agentField" />
                    <xsl:call-template name="directField" />
                </div>
                <div class="InformationCols-item">
                    <xsl:call-template name="issuerLicenseField" />

                    <xsl:if test="$licenseType = 'license'">
                        <xsl:if test="$area = 'ca_license'">
                            <xsl:call-template name="issuerSongField" />
                        </xsl:if>
                        <xsl:call-template name="crossedField" />
                    </xsl:if>

                    <xsl:call-template name="statusField" />
                </div>
            </div>
        </fieldset>
    </xsl:template>

    <xsl:template name="dateSection">
        <fieldset class="Form-fieldset LicenseEdit-fieldset">
            <h3>Dates</h3>
            <div class="InformationCols">
                <div class="InformationCols-item InformationCols-item-double">
                    <div class="Form-group Form-group-horizontal">
                        <xsl:call-template name="termStartField" />
                        <xsl:call-template name="termEndField" />
                    </div>
                    <div class="Form-group Form-group-horizontal">
                        <xsl:call-template name="dateSentField" />
                        <xsl:call-template name="dateReceivedField" />
                        <xsl:call-template name="dateIssuedField" />
                    </div>
                </div>
            </div>
        </fieldset>
    </xsl:template>

    <xsl:template name="ratesSection">
        <fieldset class="Form-fieldset LicenseEdit-fieldset">
            <h3>Rates</h3>
            <div class="InformationCols">
                <div class="InformationCols-item">
                    <xsl:call-template name="rateTypeField" />
                    <xsl:call-template name="ratePercentField" />
                    <xsl:call-template name="rateBasisField" />
                    <xsl:call-template name="pennyRateField" />
                </div>
            </div>
            <div class="InformationCols">
                <div class="InformationCols-item InformationCols-item-double">
                    <div class="LicenseEdit-percents-section">
                        <div class="Form-group Form-group-horizontal LicenseEdit-percents-group">
                            <xsl:call-template name="salesPercentField" />
                            <xsl:call-template name="freeGoodsField" />
                            <xsl:call-template name="miscField" />
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </xsl:template>

    <xsl:template name="reservesSection">
        <div class="Form-fieldset LicenseEdit-fieldset">
            <h3>Reserves</h3>
            <div class="InformationCols">
                <div class="InformationCols-item InformationCols-item-double">
                    <fieldset class="Form-fieldset">
                        <xsl:call-template name="reserveField" />
                    </fieldset>
                    <xsl:if test="$licenseType = 'license'">
                        <fieldset class="Form-fieldset">
                            <xsl:call-template name="liquidationScheduleFields" />
                        </fieldset>
                    </xsl:if>
                    <fieldset class="Form-fieldset">
                        <xsl:call-template name="digitalReservesField" />
                    </fieldset>
                </div>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="commentSection">
        <fieldset class="Form-fieldset LicenseEdit-fieldset">
            <h3>Comments</h3>
            <div class="InformationCols">
                <div class="InformationCols-item">
                    <xsl:call-template name="commentsField" />
                </div>
            </div>
        </fieldset>
    </xsl:template>

    <xsl:template name="licenseFields">
        <xsl:call-template name="ownershipSection" />
        <xsl:call-template name="dateSection" />

        <xsl:if test="$licenseType = 'license' or $licenseType = 'ringtone'">
            <xsl:call-template name="ratesSection" />
            <xsl:if test="$licenseType != 'ringtone'">
                <xsl:call-template name="reservesSection" />
            </xsl:if>
            <xsl:call-template name="commentSection" />
        </xsl:if>
    </xsl:template>

    <xsl:template name="publicFields">
        <fieldset class="Form-fieldset LicenseEdit-fieldset">
            <div class="InformationCols">
                <div class="InformationCols-item">
                    <xsl:call-template name="shareField" />
                    <xsl:call-template name="statusField" />
                </div>
            </div>
        </fieldset>
    </xsl:template>

    <xsl:template name="productTypeField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/TrackLicense/ProductTypeID[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_ProductTypeID">
                <span class="Form-label-caption">Product Type</span>
                <xsl:call-template name="helpIcon">
                    <xsl:with-param name="tip">If &quot;All Products&quot; or a Digital product is selected, Region&lt;br&gt;must include only United States and/or Canada.</xsl:with-param>
                </xsl:call-template>
            </label>
            <div class="Form-input-wrapper">

                <xsl:variable name="licenseTrackProductItems">
                    <map>
                        <mapEntry><name>All Products</name><value></value></mapEntry>
                        <mapEntry><name>All Physical Products</name><value>255</value></mapEntry>
                        <xsl:for-each select="Form/TypeList/Type[Type = 1]">
                            <mapEntry>
                                <name>&#160;&#160;&#160;&#160;<xsl:value-of select="Description" /></name>
                                <value><xsl:value-of select="ProductTypeID" /></value>
                            </mapEntry>
                        </xsl:for-each>
                        <mapEntry><name>All Digital Products</name><value>254</value></mapEntry>
                        <xsl:for-each select="Form/TypeList/Type[Type = 2 and ProductTypeID != 15]">
                            <mapEntry>
                                <name>&#160;&#160;&#160;&#160;<xsl:value-of select="Description" /></name>
                                <value><xsl:value-of select="ProductTypeID" /></value>
                            </mapEntry>
                        </xsl:for-each>

                    </map>
                </xsl:variable>
                <xsl:call-template name="uiDropdown">
                    <xsl:with-param name="items" select="$licenseTrackProductItems"/>
                    <xsl:with-param name="id" select="'Form_TrackLicense_ProductTypeID'"/>
                    <xsl:with-param name="name" select="'Form_TrackLicense_ProductTypeID'"/>
                    <xsl:with-param name="active" select="Form/TrackLicense/ProductTypeID"/>
                    <xsl:with-param name="onChange">
                        <xsl:if test="$licenseType = 'license'">
                            <xsl:text>digitalReservesTest(this.value)</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1 or ($cmd != 'copy' and Form/TrackLicense/InUse = 1)">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/ProductTypeID</xsl:with-param>
                <xsl:with-param name="displayName">Product Type</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="ringtoneField">
        <tr>
            <td class="leftCol"><label for="Form_TrackLicense_ProductTypeID">Product Type:</label></td>
            <td class="readOnlyCol">
                RING
                <input type="hidden" name="Form_TrackLicense_ProductTypeID" id="Form_TrackLicense_ProductTypeID" value="15" />
                <xsl:call-template name="helpIcon">
                    <xsl:with-param name="tip">Region must include only United States and/or Canada.</xsl:with-param>
                </xsl:call-template>
            </td>
        </tr>
    </xsl:template>


    <xsl:template name="regionField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/TrackLicense/RegionID[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <input type="hidden" name="Form_TrackLicense_RegionID" id="Form_TrackLicense_RegionID" >
                <xsl:attribute name="value">
                    <xsl:choose>
                        <xsl:when test="Form/TrackLicense/RegionID != 0 and Form/TrackLicense/RegionID != ''">
                            <xsl:value-of select="Form/TrackLicense/RegionID" />
                        </xsl:when>
                        <xsl:when test="Form/TrackLicense/TrackLicenseID = ''">
                            <xsl:value-of select="/Root/Form/RegionList/Region[IsDefaultMechanicalLicenseRegion = 1]/RegionID" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:attribute>
            </input>
            <label class="Form-label">
                <span class="Form-label-caption">Region</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">

                <xsl:if test="$lockedRecord = 1">
                    <xsl:attribute name="class">
                        <xsl:text>Form-input-wrapper Form-input-wrapper-compound js-tooltip</xsl:text>
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:text>Region cannot be changed for this license</xsl:text>
                    </xsl:attribute>
                </xsl:if>

                <div id="regionNameWrapper" class="Form-input Input Input-readonly">
                    <xsl:variable name="defaultRegionName" select="Form/RegionList/Region[IsDefaultMechanicalLicenseRegion = 1]/Name" />

                    <xsl:choose>
                        <xsl:when test="Form/TrackLicense/RegionID != 0 and Form/TrackLicense/RegionID != ''">
                            <xsl:variable name="regionID" select="Form/TrackLicense/RegionID" />
                            <xsl:variable name="regionName" select="/Root/Form/RegionList/Region[RegionID = $regionID]/Name" />
                            <xsl:choose>
                                <xsl:when test="substring($regionName,26,1)">
                                    <abbr title="{$regionName}"><xsl:value-of select="substring($regionName,1,25)" />...</abbr>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="$regionName" />
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:when test="Form/TrackLicense/TrackLicenseID = ''">
                            <xsl:choose>
                                <xsl:when test="substring($defaultRegionName,26,1)">
                                    <abbr title="{$defaultRegionName}"><xsl:value-of select="substring($defaultRegionName,1,25)" />...</abbr>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="$defaultRegionName" />
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                    </xsl:choose>
                </div>

                <xsl:if test="$lockedRecord != 1">
                    <div class="Form-input-additive">
                        <div class="Icon-trigger js-tooltip" title="Region Lookup" id="regionLookup" onclick="matchLicenseRegion()">
                            <xsl:call-template name="icon">
                                <xsl:with-param name="type" select="'edit'" />
                                <xsl:with-param name="role" select="'action'" />
                            </xsl:call-template>
                        </div>
                    </div>
                </xsl:if>

            </div>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/RegionID</xsl:with-param>
                <xsl:with-param name="displayName">Region</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="shareField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required Form-item-percents-field</xsl:text>
                <xsl:if test="Form/TrackLicense/Share[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_Share">
                <span class="Form-label-caption">Share</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">
                <input type="text" class="Input Form-input" name="Form_TrackLicense_Share" id="Form_TrackLicense_Share">
                    <xsl:if test="Form/TrackLicense/Share != '' and Form/TrackLicense/Share != 0">
                        <xsl:attribute name="value"><xsl:value-of select="Form/TrackLicense/Share" /></xsl:attribute>
                    </xsl:if>
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
                <div class="Form-input-additive">
                    %
                </div>
            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/Share</xsl:with-param>
                <xsl:with-param name="displayName">Share</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="payorField">
        <div class="Form-item">
            <label class="Form-label" for="Form_TrackLicense_PayorID">
                <span class="Form-label-caption">Payor</span>
            </label>
            <div class="Form-input-wrapper">
                <xsl:variable name="licenseTrackPayorItems">
                    <map>
                        <xsl:for-each select="Form/PayorList/Payor">
                            <mapEntry>
                                <name><xsl:value-of select="Name" /></name>
                                <value><xsl:value-of select="PayorID" /></value>
                            </mapEntry>
                        </xsl:for-each>
                    </map>
                </xsl:variable>
                <xsl:call-template name="uiDropdown">
                    <xsl:with-param name="items" select="$licenseTrackPayorItems"/>
                    <xsl:with-param name="id" select="'Form_TrackLicense_PayorID'"/>
                    <xsl:with-param name="name" select="'Form_TrackLicense_PayorID'"/>
                    <xsl:with-param name="active" select="/Root/Form/TrackLicense/PayorID"/>
                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1 or ($cmd != 'copy' and Form/TrackLicense/InUse = 1)">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="publisherField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/TrackLicense/PublisherID[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_PublisherID">
                <span class="Form-label-caption">Publisher</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">

                <xsl:if test="$lockedRecord = 1">
                    <xsl:attribute name="class">
                        <xsl:text>Form-input-wrapper Form-input-wrapper-compound js-tooltip</xsl:text>
                    </xsl:attribute>
                    <xsl:attribute name="title">
                        <xsl:text>Publisher cannot be changed for this license</xsl:text>
                    </xsl:attribute>
                </xsl:if>

                <input type="hidden" name="Form_TrackLicense_PublisherID" id="Form_TrackLicense_PublisherID" value="{Form/TrackLicense/PublisherID}" />

                <div id="publisherNameWrapper" class="Input Input-readonly">
                    <xsl:choose>
                        <xsl:when test="normalize-space(Form/TrackLicense/PublisherID) and substring(Form/TrackLicense/Publisher/PublisherName,26,1)">
                            <abbr title="{Form/TrackLicense/Publisher/PublisherName}"><xsl:value-of select="substring(Form/TrackLicense/Publisher/PublisherName,1,25)" />...</abbr>
                        </xsl:when>
                        <xsl:when test="normalize-space(Form/TrackLicense/PublisherID)">
                            <xsl:value-of select="Form/TrackLicense/Publisher/PublisherName" />
                        </xsl:when>
                        <xsl:otherwise>
                            (none)
                        </xsl:otherwise>
                    </xsl:choose>
                </div>

                <xsl:if test="$lockedRecord != 1">
                    <div class="Form-input-additive">
                        <div class="Icon-trigger js-tooltip" title="Publisher Lookup" id="publisherLookup" onclick="matchLicensePublisher('{$area}')">
                            <xsl:call-template name="icon">
                                <xsl:with-param name="type" select="'edit'" />
                                <xsl:with-param name="role" select="'action'" />
                            </xsl:call-template>
                        </div>
                    </div>
                </xsl:if>

            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/PublisherID</xsl:with-param>
                <xsl:with-param name="displayName">Publisher</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="adminField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
            </xsl:attribute>
            <label class="Form-label">
                <span class="Form-label-caption">Admin</span>
            </label>
            <div class="Form-input-wrapper">
                <span id="PublisherAdmin" class="Form-input Input Input-readonly">
                    <xsl:if test="Form/TrackLicense/PublisherDirect = 1">
                        <xsl:attribute name="class">subtle</xsl:attribute>
                    </xsl:if>
                    <xsl:value-of select="Form/TrackLicense/Publisher/AdminName" />
                </span>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="agentField">

        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
            </xsl:attribute>
            <label class="Form-label">
                <span class="Form-label-caption">Agent</span>
            </label>
            <div class="Form-input-wrapper">
                <span id="PublisherAgent" class="Form-input Input Input-readonly">
                    <xsl:if test="Form/TrackLicense/PublisherDirect = 1">
                        <xsl:attribute name="class">subtle</xsl:attribute>
                    </xsl:if>
                    <xsl:value-of select="Form/TrackLicense/Publisher/AgentName" />
                </span>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="directField">

        <div class="Form-item">
            <div class="Form-input-wrapper">
                <xsl:call-template name="uiCheckbox">
                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="caption" select="'Publisher Direct'"/>
                    <xsl:with-param name="checked">
                        <xsl:if test="Form/TrackLicense/PublisherDirect = 1">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="name" select="'Trigger_Form_TrackLicense_PublisherDirect'"/>
                    <xsl:with-param name="onClick">
                        <xsl:text>checkCheckBox(this,'Form_TrackLicense_PublisherDirect'); toggleAdminAgent(this);</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name="id" select="'Trigger_Form_TrackLicense_PublisherDirect'" />
                    <xsl:with-param name="value" select="'1'"/>
                </xsl:call-template>
            </div>
            <input type="hidden" name="Form_TrackLicense_PublisherDirect" id="Form_TrackLicense_PublisherDirect">
                <xsl:if test="Form/TrackLicense/PublisherDirect = 1">
                    <xsl:attribute name="value">1</xsl:attribute>
                </xsl:if>
            </input>
        </div>
    </xsl:template>


    <xsl:template name="issuerLicenseField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/IssuerLicenseID[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_IssuerLicenseID">
                <span class="Form-label-caption">Issuer License ID</span>
            </label>
            <div class="Form-input-wrapper">
                <input type="text" name="Form_TrackLicense_IssuerLicenseID" id="Form_TrackLicense_IssuerLicenseID" value="{Form/TrackLicense/IssuerLicenseID}" class="Form-input Input">
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/IssuerLicenseID</xsl:with-param>
                <xsl:with-param name="displayName">Issuer License ID</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="issuerSongField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/IssuerSongID[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_IssuerSongID">
                <span class="Form-label-caption">Issuer Song ID</span>
            </label>
            <div class="Form-input-wrapper">
                <input type="text" name="Form_TrackLicense_IssuerSongID" id="Form_TrackLicense_IssuerSongID" value="{Form/TrackLicense/IssuerSongID}" class="Form-input Input">
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
            </div>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/IssuerSongID</xsl:with-param>
                <xsl:with-param name="displayName">Issuer Song ID</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="crossedField">
        <div class="Form-item">
            <label class="Form-label" for="Form_TrackLicense_CrossCollateralized">
                <span class="Form-label-caption">Crossed</span>
            </label>
            <div class="Form-input-wrapper">
                <xsl:variable name="licenseTrackCrossCollateralizedItems">
                    <map>
                        <mapEntry>
                            <name>No</name>
                            <value>0</value>
                            <selected>
                                <xsl:if test="Form/TrackLicense/CrossCollateralized != 1">
                                    <xsl:text>true</xsl:text>
                                </xsl:if>
                            </selected>
                        </mapEntry>
                        <mapEntry>
                            <name>Yes</name>
                            <value>1</value>
                            <selected>
                                <xsl:if test="Form/TrackLicense/CrossCollateralized = 1">
                                    <xsl:text>true</xsl:text>
                                </xsl:if>
                            </selected>
                        </mapEntry>
                    </map>
                </xsl:variable>
                <xsl:call-template name="uiDropdown">
                    <xsl:with-param name="items" select="$licenseTrackCrossCollateralizedItems"/>
                    <xsl:with-param name="id" select="'Form_TrackLicense_CrossCollateralized'"/>
                    <xsl:with-param name="name" select="'Form_TrackLicense_CrossCollateralized'"/>

                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="statusField">
        <div class="Form-item">
            <label class="Form-label" for="Form_TrackLicense_Inactive">
                <span class="Form-label-caption">Status</span>
            </label>
            <div class="Form-input-wrapper">
                <xsl:variable name="licenseTrackInactiveItems">
                    <map>
                        <mapEntry>
                            <name>Active</name>
                            <value>0</value>
                            <selected>
                                <xsl:if test="Form/TrackLicense/Inactive != 1">
                                    <xsl:text>true</xsl:text>
                                </xsl:if>
                            </selected>
                        </mapEntry>
                        <mapEntry>
                            <name>Inactive</name>
                            <value>1</value>
                            <selected>
                                <xsl:if test="Form/TrackLicense/Inactive = 1">
                                    <xsl:text>true</xsl:text>
                                </xsl:if>
                            </selected>
                        </mapEntry>
                    </map>
                </xsl:variable>
                <xsl:call-template name="uiDropdown">
                    <xsl:with-param name="items" select="$licenseTrackInactiveItems"/>
                    <xsl:with-param name="id" select="'Form_TrackLicense_Inactive'"/>
                    <xsl:with-param name="name" select="'Form_TrackLicense_Inactive'"/>
                    <xsl:with-param name="active" select="Form/TrackLicense/Inactive"/>
                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="dateSentField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/DateSent[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_DateSent">
                <span class="Form-label-caption">Date Sent</span>
            </label>
            <div class="Form-input-wrapper">

                <xsl:variable name="dateSentPath">Form/TrackLicense/DateSent</xsl:variable>
                <xsl:call-template name="uiDatepicker">
                    <xsl:with-param name="id" select="'Form_TrackLicense_DateSent'" />
                    <xsl:with-param name="wrapperId" select="'Form_TrackLicense_DateSent_TD'" />
                    <xsl:with-param name="name" select="'Form_TrackLicense_DateSent'" />
                    <xsl:with-param name="value">
                        <xsl:value-of select="dyn:evaluate($dateSentPath)" />
                    </xsl:with-param>

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

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/DateSent</xsl:with-param>
                <xsl:with-param name="displayName">Date Sent</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="dateReceivedField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/DateReceived[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_DateReceived">
                <span class="Form-label-caption">Date Received</span>
            </label>
            <div class="Form-input-wrapper">
                <xsl:variable name="dateReceivedPath">Form/TrackLicense/DateReceived</xsl:variable>
                <xsl:call-template name="uiDatepicker">
                    <xsl:with-param name="id" select="'Form_TrackLicense_DateReceived'" />
                    <xsl:with-param name="name" select="'Form_TrackLicense_DateReceived'" />
                    <xsl:with-param name="wrapperId" select="'Form_TrackLicense_DateReceived_TD'" />
                    <xsl:with-param name="value">
                        <xsl:value-of select="dyn:evaluate($dateReceivedPath)" />
                    </xsl:with-param>

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

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/DateReceived</xsl:with-param>
                <xsl:with-param name="displayName">Date Received</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="dateIssuedField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/DateIssued[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_DateIssued">
                <span class="Form-label-caption">Date Issued</span>
            </label>
            <div class="Form-input-wrapper">

                <xsl:variable name="dateIssuedPath">Form/TrackLicense/DateIssued</xsl:variable>
                <xsl:call-template name="uiDatepicker">
                    <xsl:with-param name="id" select="'Form_TrackLicense_DateIssued'" />
                    <xsl:with-param name="name" select="'Form_TrackLicense_DateIssued'" />
                    <xsl:with-param name="wrapperId" select="'Form_TrackLicense_DateIssued_TD'" />
                    <xsl:with-param name="value">
                        <xsl:value-of select="dyn:evaluate($dateIssuedPath)" />
                    </xsl:with-param>

                    <xsl:with-param name="className" select="'LicenseIncome-table-input'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1">
                            <xsl:text name="disabled">true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </div>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/DateIssued</xsl:with-param>
                <xsl:with-param name="displayName">Date Issued</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="termStartField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/TermStart[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_TermStart">
                <span class="Form-label-caption">Term Start</span>
            </label>
            <div class="Form-input-wrapper">

                <xsl:variable name="termStartPath">Form/TrackLicense/TermStart</xsl:variable>
                <xsl:call-template name="uiDatepicker">
                    <xsl:with-param name="id" select="'Form_TrackLicense_TermStart'" />
                    <xsl:with-param name="name" select="'Form_TrackLicense_TermStart'" />
                    <xsl:with-param name="wrapperId" select="'Form_TrackLicense_TermStart_TD'" />
                    <xsl:with-param name="value">
                        <xsl:value-of select="dyn:evaluate($termStartPath)" />
                    </xsl:with-param>

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

            </div>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/TermStart</xsl:with-param>
                <xsl:with-param name="displayName">Term Start</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="termEndField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/TermEnd[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_TermEnd">
                <span class="Form-label-caption">Term End</span>
            </label>
            <div class="Form-input-wrapper">

                <xsl:variable name="termEndPath">Form/TrackLicense/TermEnd</xsl:variable>
                <xsl:call-template name="uiDatepicker">
                    <xsl:with-param name="id" select="'Form_TrackLicense_TermEnd'" />
                    <xsl:with-param name="name" select="'Form_TrackLicense_TermEnd'" />
                    <xsl:with-param name="wrapperId" select="'Form_TrackLicense_TermEnd_TD'" />
                    <xsl:with-param name="value">
                        <xsl:value-of select="dyn:evaluate($termEndPath)" />
                    </xsl:with-param>

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

            </div>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/TermEnd</xsl:with-param>
                <xsl:with-param name="displayName">Term End</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="rateTypeField">

        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/TrackLicense/RateType[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_RateType">
                <span class="Form-label-caption">Rate Type</span>
            </label>
            <div class="Form-input-wrapper">

                <xsl:variable name="licenseTrackRateTypeItems">
                    <map>
                        <mapEntry><name>Choose...</name><value></value></mapEntry>

                        <xsl:if test="$licenseType = 'license'">
                            <mapEntry>
                                <value>1</value>
                                <name><xsl:value-of select="$licenseCountry" /> Stat Rate</name>
                            </mapEntry>
                            <mapEntry>
                                <value>2</value>
                                <name><xsl:value-of select="$licenseCountry" /> Minimum Stat</name>
                            </mapEntry>
                        </xsl:if>

                        <xsl:if test="$licenseType = 'ringtone'">
                            <mapEntry>
                                <value>1</value>
                                <name><xsl:value-of select="$licenseCountry" /> Ring Rate</name>
                            </mapEntry>
                        </xsl:if>
                        <mapEntry>
                            <value>3</value>
                            <name>Penny Rate (<xsl:value-of select="$licenseCurrency" />)</name>
                        </mapEntry>
                    </map>
                </xsl:variable>
                <xsl:call-template name="uiDropdown">
                    <xsl:with-param name="items" select="$licenseTrackRateTypeItems"/>
                    <xsl:with-param name="id" select="'Form_TrackLicense_RateType'"/>
                    <xsl:with-param name="name" select="'Form_TrackLicense_RateType'"/>
                    <xsl:with-param name="active" select="Form/TrackLicense/RateType"/>
                    <xsl:with-param name="onChange">
                        <xsl:text>checkLicenseRateType(this);</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1 or ($cmd != 'copy' and Form/TrackLicense/InUse = 1)">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>

            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/RateType</xsl:with-param>
                <xsl:with-param name="displayName">Rate Type</xsl:with-param>
            </xsl:call-template>
            <xsl:if test="normalize-space(Form/TrackLicense/RateType)">
                <script type="text/javascript">
                    <xsl:choose>
                        <xsl:when test="Form/TrackLicense/RateType = 3">
                            requireField('Form_TrackLicense_PennyRate','Penny Rate must be entered.');
                        </xsl:when>
                        <xsl:otherwise>
                            requireField('Form_TrackLicense_RateBasis','Rate Basis must be selected.');
                            requireField('Form_TrackLicense_RatePercentage','Rate Percent cannot be blank.');
                        </xsl:otherwise>
                    </xsl:choose>
                </script>
            </xsl:if>
        </div>
    </xsl:template>

    <xsl:template name="ratePercentField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required Form-item-percents-field</xsl:text>
                <xsl:if test="Form/TrackLicense/RatePercentage[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
                <xsl:if test="Form/TrackLicense/RateType = '3' or Form/TrackLicense/RateType =''">
                    <xsl:text> AnimateReveal AnimateReveal-hidden</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_RatePercentage">
                <span class="Form-label-caption">Rate Percent</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">

                <input type="text" name="Form_TrackLicense_RatePercentage" id="Form_TrackLicense_RatePercentage" value="{Form/TrackLicense/RatePercentage}" class="Form-input Input">
                    <xsl:if test="$lockedRecord = 1 or Form/TrackLicense/RateType = 3 or ($cmd != 'copy' and Form/TrackLicense/InUse = 1)">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
                <div class="Form-input-additive">%</div>
            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/RatePercentage</xsl:with-param>
                <xsl:with-param name="displayName">Rate Percent</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="rateBasisField">

        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/TrackLicense/RateBasis[@e] != '' or Form/TrackLicense/LockDate[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
                <xsl:if test="Form/TrackLicense/RateType = '3' or Form/TrackLicense/RateType = ''">
                    <xsl:text> AnimateReveal AnimateReveal-hidden</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_RateBasis">
                <span class="Form-label-caption">Rate Basis</span>
            </label>
            <div class="Form-input-wrapper">

                <xsl:variable name="licenseTrackRateBasisItems">
                    <map>
                        <mapEntry><name>Choose...</name><value></value></mapEntry>
                        <mapEntry><name>Lock Date</name><value>2</value></mapEntry>
                        <mapEntry><name>Sales Date</name><value>1</value></mapEntry>
                    </map>
                </xsl:variable>
                <xsl:call-template name="uiDropdown">
                    <xsl:with-param name="items" select="$licenseTrackRateBasisItems"/>
                    <xsl:with-param name="id" select="'Form_TrackLicense_RateBasis'"/>
                    <xsl:with-param name="name" select="'Form_TrackLicense_RateBasis'"/>
                    <xsl:with-param name="active" select="Form/TrackLicense/RateBasis"/>
                    <xsl:with-param name="onChange">
                        <xsl:text>checkLicenseRateBasis(this);</xsl:text>
                    </xsl:with-param>
                    <xsl:with-param name="disabled">
                        <xsl:if test="$lockedRecord = 1 or Form/TrackLicense/RateType = 3 or ($cmd != 'copy' and Form/TrackLicense/InUse = 1)">
                            <xsl:text>true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>

            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/RateBasis</xsl:with-param>
                <xsl:with-param name="displayName">Rate Basis</xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/LockDate</xsl:with-param>
                <xsl:with-param name="displayName">Lock Date</xsl:with-param>
            </xsl:call-template>
        </div>

        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/RateBasis != '2' or Form/TrackLicense/RateBasis = '' or Form/TrackLicense/RateType = '3'">
                    <xsl:text> AnimateReveal AnimateReveal-hidden</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <xsl:variable name="disableLockDate">
                <xsl:if test="$lockedRecord = 1 or Form/TrackLicense/RateBasis != 2 or Form/TrackLicense/RateBasis = '' or Form/TrackLicense/RateType = 3 or ($cmd != 'copy' and Form/TrackLicense/InUse = 1)">1</xsl:if>
            </xsl:variable>

            <label class="Form-label" for="Form_TrackLicense_LockDate">
                <span class="Form-label-caption">Lock Date</span>
            </label>
            <div class="Form-input-wrapper">
                <xsl:variable name="termEndPath">Form/TrackLicense/TermEnd</xsl:variable>
                <xsl:call-template name="uiDatepicker">
                    <xsl:with-param name="id" select="'Form_TrackLicense_LockDate'" />
                    <xsl:with-param name="name" select="'Form_TrackLicense_LockDate'" />
                    <xsl:with-param name="value" select="Form/TrackLicense/LockDate" />
                    <xsl:with-param name="className" select="'LicenseIncome-table-input'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="$disableLockDate = 1">
                            <xsl:text name="disabled">true</xsl:text>
                        </xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="pennyRateField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/TrackLicense/PennyRate[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
                <xsl:if test="Form/TrackLicense/RateType != '3'">
                    <xsl:text> AnimateReveal AnimateReveal-hidden</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_PennyRate">
                <span class="Form-label-caption">
                    Penny Rate (<xsl:value-of select="$licenseCurrency" />)
                </span>
                <xsl:call-template name="helpIcon">
                    <xsl:with-param name="tip">Share percentage is not included in penny rate mechanical license calculations.</xsl:with-param>
                </xsl:call-template>
            </label>
            <div class="Form-input-wrapper">
                <input type="text" class="Form-input Input" name="Form_TrackLicense_PennyRate" id="Form_TrackLicense_PennyRate" value="{Form/TrackLicense/PennyRate}">
                    <xsl:if test="Form/TrackLicense/RateType != '3' or $lockedRecord = 1 or ($cmd != 'copy' and Form/TrackLicense/InUse = 1)">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>

            </div>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/PennyRate</xsl:with-param>
                <xsl:with-param name="displayName">Penny Rate</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="reserveField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-percents-field</xsl:text>
                <xsl:if test="Form/TrackLicense/ReservePercentage[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_ReservePercentage">
                <span class="Form-label-caption">Reserve Percent</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">
                <input type="text" class="Form-input Input" name="Form_TrackLicense_ReservePercentage" id="Form_TrackLicense_ReservePercentage" value="{Form/TrackLicense/ReservePercentage}">
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
                <div class="Form-input-additive">%</div>
            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/ReservePercentage</xsl:with-param>
                <xsl:with-param name="displayName">Reserve Percentage</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="liquidationScheduleFields">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/ReserveLiquidationList[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <div class="Form-label">
                <span class="Form-label-caption">Liquidation Schedule</span>
                <div class="Form-input-wrapper">
                    <xsl:call-template name="liquidationSchedule">
                        <xsl:with-param name="liquidationPrefix">Form_TrackLicense_ReserveLiquidationList_ReserveLiquidation_</xsl:with-param>
                        <xsl:with-param name="liquidationList" select="Form/TrackLicense/ReserveLiquidationList/ReserveLiquidation" />
                        <xsl:with-param name="liquidationID" select="Form/TrackLicense/TrackLicenseID" />
                        <xsl:with-param name="lockedRecord" select="$lockedRecord" />
                    </xsl:call-template>
                </div>
            </div>
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/ReserveLiquidationList</xsl:with-param>
                <xsl:with-param name="displayName">Liquidation Schedule</xsl:with-param>
            </xsl:call-template>

        </div>
    </xsl:template>


    <xsl:template name="digitalReservesField">
        <xsl:variable name="productTypeID" select="Form/TrackLicense/ProductTypeID" />

        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required</xsl:text>
                <xsl:if test="Form/TrackLicense/DigitalReservesEnabled[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
                <xsl:if test="$productTypeID != '' and $productTypeID != '3' and $productTypeID != '4' and $productTypeID != '254'">
                    <xsl:text> AnimateReveal AnimateReveal-hidden</xsl:text>
                </xsl:if>
            </xsl:attribute>

            <div class="Form-input-wrapper Form-input-wrapper-compound">
                <div>
                    <xsl:call-template name="uiCheckbox">
                        <xsl:with-param name="disabled">
                            <xsl:if test="$openRuns = 1 or ($productTypeID != '' and $productTypeID != 3 and $productTypeID != 4 and $productTypeID != 254)">
                                <xsl:text>true</xsl:text>
                            </xsl:if>
                        </xsl:with-param>
                        <xsl:with-param name="caption" select="'Digital Reserves'"/>
                        <xsl:with-param name="checked">
                            <xsl:if test="Form/TrackLicense/DigitalReservesEnabled = 1">
                                <xsl:text>true</xsl:text>
                            </xsl:if>
                        </xsl:with-param>
                        <xsl:with-param name="name" select="'Trigger_Form_TrackLicense_DigitalReservesEnabled'"/>
                        <xsl:with-param name="onClick">
                            <xsl:text>checkCheckBox(this,'Form_TrackLicense_DigitalReservesEnabled')</xsl:text>
                        </xsl:with-param>
                        <xsl:with-param name="id" select="'Trigger_Form_TrackLicense_DigitalReservesEnabled'"/>
                        <xsl:with-param name="value" select="'1'"/>
                    </xsl:call-template>
                </div>
                <div class="Form-input-additive">
                    <xsl:call-template name="helpIcon">
                        <xsl:with-param name="tip">Checking this box allows you to apply reserves to digital download sales.</xsl:with-param>
                    </xsl:call-template>
                </div>

            </div>
            <input type="hidden" name="Form_TrackLicense_DigitalReservesEnabled" id="Form_TrackLicense_DigitalReservesEnabled" value="{Form/TrackLicense/DigitalReservesEnabled}" />
            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/DigitalReservesEnabled</xsl:with-param>
                <xsl:with-param name="displayName">Digital Reserve</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>


    <xsl:template name="salesPercentField">

        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-required Form-item-percents-field</xsl:text>
                <xsl:if test="Form/TrackLicense/PercentageOfSales[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_PercentageOfSales">
                <span class="Form-label-caption">
                    Percent of Sales
                </span>
                <xsl:call-template name="helpIcon">
                    <xsl:with-param name="tip">Sets percentage of sales that will be paid on.</xsl:with-param>
                </xsl:call-template>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">
                <input type="text" class="Form-input Input" name="Form_TrackLicense_PercentageOfSales" id="Form_TrackLicense_PercentageOfSales" value="{Form/TrackLicense/PercentageOfSales}">
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
                <div class="Form-input-additive">%</div>
            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/PercentageOfSales</xsl:with-param>
                <xsl:with-param name="displayName">Percent of Sales</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="packagingField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item</xsl:text>
                <xsl:if test="Form/TrackLicense/PackagingDeduction[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_PackagingDeduction">
                <span class="Form-label-caption">Packaging</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">
                <input type="text" class="Form-input Input" name="Form_TrackLicense_PackagingDeduction" id="Form_TrackLicense_PackagingDeduction" value="{Form/TrackLicense/PackagingDeduction}">
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
                <div class="Form-input-additive">%</div>

            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/PackagingDeduction</xsl:with-param>
                <xsl:with-param name="displayName">Packaging Deduction</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="freeGoodsField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-percents-field</xsl:text>
                <xsl:if test="Form/TrackLicense/FreeGoods[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_FreeGoods">
                <span class="Form-label-caption">Free Goods</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">
                <input type="text" class="Form-input Input" name="Form_TrackLicense_FreeGoods" id="Form_TrackLicense_FreeGoods" value="{Form/TrackLicense/FreeGoods}">
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
                <div class="Form-input-additive">%</div>
            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/FreeGoods</xsl:with-param>
                <xsl:with-param name="displayName">Free Goods</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="miscField">
        <div>
            <xsl:attribute name="class">
                <xsl:text>Form-item Form-item-percents-field</xsl:text>
                <xsl:if test="Form/TrackLicense/MiscDeduction[@e] != ''">
                    <xsl:text> Form-item-error</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <label class="Form-label" for="Form_TrackLicense_MiscDeduction">
                <span class="Form-label-caption">Misc Deduction</span>
            </label>
            <div class="Form-input-wrapper Form-input-wrapper-compound">
                <input type="text" class="Form-input Input" name="Form_TrackLicense_MiscDeduction" id="Form_TrackLicense_MiscDeduction" value="{Form/TrackLicense/MiscDeduction}">
                    <xsl:if test="$lockedRecord = 1">
                        <xsl:attribute name="disabled">disabled</xsl:attribute>
                    </xsl:if>
                </input>
                <div class="Form-input-additive">%</div>

            </div>

            <xsl:call-template name="inlineError">
                <xsl:with-param name="path">Form/TrackLicense/MiscDeduction</xsl:with-param>
                <xsl:with-param name="displayName">Misc Deduction</xsl:with-param>
            </xsl:call-template>
        </div>
    </xsl:template>

    <xsl:template name="commentsField">

        <div class="Form-item">
            <label class="Form-label" for="Form_TrackLicense_Comments">
                <span class="Form-label-caption">Comments</span>
            </label>
            <div class="Form-input-wrapper">
                <textarea rows="6" cols="40" class="Form-input Input Input-textarea" name="Form_TrackLicense_Comments"><xsl:if test="$lockedRecord &gt; 0"><xsl:attribute name="disabled">disabled</xsl:attribute></xsl:if><xsl:value-of select="Form/TrackLicense/Comments" /></textarea>
            </div>
        </div>
    </xsl:template>


    <xsl:template name="submitButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="type" select="'primary'"/>
            <xsl:with-param name="disabled">
                <xsl:if test="($licenseType = 'ccomp' and Form/TrackLicense/NoValidRegion) or $lockedRecord = 1">
                    <xsl:text>true</xsl:text>
                </xsl:if>
            </xsl:with-param>
            <xsl:with-param name="content">
                <xsl:choose>
                    <xsl:when test="$cmd = 'copy'">Copy</xsl:when>
                    <xsl:when test="normalize-space(Params/TrackLicenseID)">Update</xsl:when>
                    <xsl:when test="not(normalize-space(Params/TrackLicenseID))">Create</xsl:when>
                </xsl:choose>
            </xsl:with-param>
            <xsl:with-param name="elemType" select="'submit'"/>
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="id" select="'submitButton'" />
            <xsl:with-param name="name" select="'Submit'" />
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="cancelButton">
        <xsl:if test="normalize-space(Form/TrackLicense/TrackLicenseID) and $cmd != 'copy'">

            <xsl:call-template name="uiButton">
                <xsl:with-param name="disabled">
                    <xsl:if test="Form/TrackLicense/Status != 1 or Form/TrackLicense/InUse = 1 or $lockedRecord = 1 or Form/TrackLicense/HasPendingTransaction = 1">
                        <xsl:text>true</xsl:text>
                    </xsl:if>
                </xsl:with-param>
                <xsl:with-param name="content" select="'Delete'"/>
                <xsl:with-param name="className" select="'Form-button-left'" />
                <xsl:with-param name="name" select="'deleteButton'" />
                <xsl:with-param name="title">
                    <xsl:if test="Form/TrackLicense/Status != 1 or Form/TrackLicense/InUse = 1">
                        <xsl:text>This license cannot be deleted.</xsl:text>
                    </xsl:if>
                </xsl:with-param>
                <xsl:with-param name="onClick">
                    <xsl:choose>
                        <xsl:when test="Form/TrackLicense/Type = 2">
                            confirmDeleteControlledComp(<xsl:value-of select="Form/TrackLicense/TrackLicenseID" />)
                        </xsl:when>
                        <xsl:when test="Form/TrackLicense/Type = 4">
                            confirmDeletePublicDomain(<xsl:value-of select="Form/TrackLicense/TrackLicenseID" />)
                        </xsl:when>
                        <xsl:otherwise>
                            confirmDeleteLicense(<xsl:value-of select="Form/TrackLicense/TrackLicenseID" />)
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:with-param>
            </xsl:call-template>


            <div class="HelpText HelpText-bybutton">
                <xsl:choose>
                    <xsl:when test="Form/TrackLicense/Status != 1 or Form/TrackLicense/InUse = 1 or $lockedRecord = 1 or Form/TrackLicense/HasPendingTransaction = 1">
                        <span >This license cannot be deleted.&#160;</span>
                    </xsl:when>
                    <xsl:otherwise></xsl:otherwise>
                </xsl:choose>
                <xsl:if test="Form/TrackLicense/HasPendingTransaction = 1 and Form/TrackLicense/InUse != 1">
                    <span>
                        <xsl:call-template name="helpIcon" style="display: inline-block; float:left">
                            <xsl:with-param name="tip">
                                <![CDATA[
                                This license has one or more pending transactions against it. Pending transactions will need to be deleted before you can delete this license.
                                ]]>
                            </xsl:with-param>
                        </xsl:call-template>
                    </span>
                </xsl:if>
            </div>

        </xsl:if>

        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Return to Album'"/>
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="onClick">
                <xsl:choose>
                    <xsl:when test="Params/_inline">hideInlinePop()</xsl:when>
                    <xsl:otherwise>location.href='catalog?AlbumID=<xsl:value-of select="Form/Track/AlbumID" /><xsl:value-of select="Track/AlbumID" />&amp;c=show&amp;tab=<xsl:value-of select="$licenseTab" />'</xsl:otherwise>
                </xsl:choose>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="licenseCopyTracks">
        <section class="LicenseEdit-tracks">
            <h2>Tracks</h2>
            <div class="Form-header">
                <p>Select the track(s) that should receive a copy of this license.</p>
            </div>
            <fieldset class="Form-fieldset Form-fieldset-standart">
                <div>
                    <xsl:attribute name="class">
                        <xsl:text>Form-item</xsl:text>
                        <xsl:if test="TrackID[@e] != ''">
                            <xsl:text> Form-item-error</xsl:text>
                        </xsl:if>
                    </xsl:attribute>
                    <label class="Form-label" for="TrackID">
                        <span class="Form-label-caption">Tracks</span>
                    </label>
                    <div class="Form-input-wrapper">
                        <select name="TrackID" id="TrackID" multiple="multiple" class="Input Input-multiple Form-input">
                            <xsl:if test="$lockedRecord = 1">
                                <xsl:attribute name="disabled">disabled</xsl:attribute>
                            </xsl:if>
                            <xsl:for-each select="TrackList/Track">
                                <xsl:if test="TrackID != /Root/Form/TrackLicense/TrackID">
                                    <option value="{TrackID}">
                                        <xsl:variable name="trackID" select="TrackID" />
                                        <xsl:for-each select="/Root/Params/TrackID">
                                            <xsl:if test=". = $trackID">
                                                <xsl:attribute name="selected">selected</xsl:attribute>
                                            </xsl:if>
                                        </xsl:for-each>
                                        (<xsl:value-of select="TrackOrder" />) <xsl:value-of select="Title" />
                                    </option>
                                </xsl:if>
                            </xsl:for-each>
                        </select>
                    </div>

                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">TrackID</xsl:with-param>
                        <xsl:with-param name="displayName">Track</xsl:with-param>
                    </xsl:call-template>
                </div>
            </fieldset>
        </section>
    </xsl:template>

</xsl:stylesheet>
