<!--                                                                  -->
<!--  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="distributionfeeLayout">
        <script src="/production/javascript/validateDistributionFee.js?t={$now}" type="text/javascript"></script>
        <form action="javascript:streamDistributionFeeConfirm();" name="streamForm" class="Form">
            <div class="DistributionFee">
                <div class="DistributionFee-common-info">
                    <xsl:variable name="distFeeCommonInfo">
                        <map>
                            <mapEntry>
                                <name>
                                    File Name
                                </name>
                                <value>
                                    <xsl:value-of select="File/OrigFileName"/>
                                </value>
                            </mapEntry>
                            <mapEntry>
                                <name>Service</name>
                                <value>
                                    <xsl:value-of select="File/ServiceName"/>
                                </value>
                            </mapEntry>
                            <mapEntry>
                                <name>Sales Period</name>
                                <value>
                                    <xsl:value-of select="File/DateSalesFilePeriod"/>
                                </value>
                            </mapEntry>
                            <mapEntry>
                                <name>Received</name>
                                <value>
                                    <xsl:value-of select="File/DateCreatedPretty"/>
                                </value>
                            </mapEntry>
                            <mapEntry>
                                <name>Units</name>
                                <value>
                                    <xsl:value-of select="File/UnitsPretty"/>
                                </value>
                            </mapEntry>
                        </map>
                    </xsl:variable>

                    <xsl:call-template name="uiValuePair">
                        <xsl:with-param name="items" select="$distFeeCommonInfo" />
                    </xsl:call-template>
                </div>

                <xsl:if test="File/DistributionFeeFormats/@size &gt; 1">
                    <fieldset class="Form-fieldset">
                        <div class="Form-item" id="formatChoice">
                            <div class="Form_label">
                                <span class="Form-label-caption">Apply distribution fee to</span>
                                <div class="Form-input-wrapper">
                                    <div class="Form-group Form-group-horizontal">
                                        <div class="Form-item">
                                            <xsl:call-template name="uiRadio">
                                                <xsl:with-param name="name" select="'formatChoice'"/>
                                                <xsl:with-param name="caption" select="'All Formats'"/>
                                                <xsl:with-param name="value" select="'1'"/>
                                                <xsl:with-param name="onClick">
                                                    javascript:displayFormat('all');
                                                </xsl:with-param>
                                            </xsl:call-template>
                                        </div>
                                        <div class="Form-item">
                                            <xsl:call-template name="uiRadio">
                                                <xsl:with-param name="name" select="'formatChoice'"/>
                                                <xsl:with-param name="caption" select="'By Format'"/>
                                                <xsl:with-param name="checked" select="'true'"/>
                                                <xsl:with-param name="value" select="'2'"/>
                                                <xsl:with-param name="onClick">
                                                    javascript:displayFormat('per');;
                                                </xsl:with-param>
                                            </xsl:call-template>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <span id="ERRORstreamRevenue" class="Form-error"></span>
                    </fieldset>
                </xsl:if>
                <fieldset class="Form-fieldset DistributionFee-confirm-opener" id="confirmBoxOpener">
                    <fieldset class="Form-fieldset">
                        <xsl:if test="File/DistributionFeeFormats/@size = 1">
                            <input type="hidden" name="formatChoice" value="1" />
                            <div class="DistributionFee-all-formats" id="allFormats">
                                <xsl:if test="normalize-space(File/DistributionFeeFormats/Format)">
                                    <h2 class="Form-header DistributionFee-form-heading">Format <xsl:value-of select="File/DistributionFeeFormats/Format" /></h2>
                                </xsl:if>
                                <div class="Form-item">
                                    <xsl:attribute name="class">
                                        <xsl:choose>
                                            <xsl:when test="File/DistributionFeeFormats[@e !='']">
                                                <xsl:text>Form-item Form-item-error</xsl:text>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:text>Form-item</xsl:text>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:attribute>
                                    <label class="Form-label">
                                        <span class="Form-label-caption">Distribution Fee</span>
                                        <div class="Form-input-wrapper">
                                            <input
                                                type="text"
                                                name="streamDistributionFee_all"
                                                id="streamDistributionFee_all"
                                                class="Form-input Input DistributionFee-change-input"
                                            >
                                                <xsl:attribute name="value">
                                                    <xsl:for-each select="File/DistributionFeeFormats">
                                                        <xsl:value-of select="FormatValue" />
                                                    </xsl:for-each>
                                                </xsl:attribute>
                                            </input>
                                        </div>
                                    </label>
                                    <div class="Form-error-text-wrapper">
                                        <span id="ERRORstreamall" class="Form-error"></span>
                                    </div>
                                </div>
                            </div>
                        </xsl:if>
                        <xsl:if test="File/DistributionFeeFormats/@size &gt; 1">
                            <xsl:value-of select="File/DistributionFeeFormats[@e]" />
                            <xsl:value-of select="@e" />
                            <div class="DistributionFee-all-formats-list" id="allFormats">
                                <h2 class="Form-header DistributionFee-form-heading">All Formats</h2>
                                <div class="Form-item">
                                    <xsl:attribute name="class">
                                        <xsl:choose>
                                            <xsl:when test="File/DistributionFeeFormats[@e !='']">
                                                <xsl:text>Form-item Form-item-error</xsl:text>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:text>Form-item</xsl:text>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:attribute>
                                    <label class="Form-label">
                                        <span class="Form-label-caption">Distribution Fee</span>
                                        <div class="Form-input-wrapper">
                                            <input
                                                type="text"
                                                name="streamDistributionFee_all"
                                                id="streamDistributionFee_all"
                                                class="Form-input Input DistributionFee-change-input"
                                            >
                                                <xsl:attribute name="value">
                                                    <xsl:choose>
                                                        <xsl:when test="normalize-space(File/DistFeePct)">
                                                            <xsl:value-of select="File/DistFeePct" />
                                                        </xsl:when>
                                                    </xsl:choose>
                                                </xsl:attribute>
                                            </input>
                                        </div>
                                    </label>
                                    <div class="Form-error-text-wrapper">
                                        <span id="ERRORstreamall" class="Form-error"></span>
                                    </div>
                                </div>
                            </div>
                            <div class="DistributionFee-by-formats" id="byFormats">
                                <h2 class="Form-header DistributionFee-form-heading">By Format</h2>

                                <input type="hidden" name="has_mulitple_distribution" value="{File/DistributionFeeFormats/list}" id="has_mulitple_distribution" />
                                <input type="hidden" name="short_multiple_distribution" value="{File/DistributionFeeFormats/short}" id="short_multiple_distribution" />
                                <xsl:for-each select="File/DistributionFeeFormats">
                                    <div class="Form-item">
                                        <xsl:attribute name="class">
                                            <xsl:choose>
                                                <xsl:when test="File/DistributionFeeFormats[@e !='']">
                                                    <xsl:text>Form-item Form-item-error</xsl:text>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <xsl:text>Form-item</xsl:text>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                        </xsl:attribute>
                                        <label class="Form-label">
                                            <span class="Form-label-caption">Distribution Fee per <xsl:value-of select="Format" /><xsl:if test="not(normalize-space(Format))">Physical sale</xsl:if></span>
                                            <div class="Form-input-wrapper">
                                                <input
                                                    type="text"
                                                    name="streamDistributionFee_{FormatShort}"
                                                    id="streamDistributionFee_{FormatShort}"
                                                    class="Form-input Input DistributionFee-change-input"
                                                    value="{FormatValue}"
                                                />
                                            </div>
                                        </label>
                                        <div class="Form-error-text-wrapper">
                                            <span id="ERRORstream{Format}" class="Form-error"></span>
                                        </div>
                                    </div>
                                </xsl:for-each>
                            </div>
                        </xsl:if>

                    </fieldset>
                    <fieldset class="Form-fieldset Form-fieldset-buttons">
                        <xsl:call-template name="uiButton">
                            <xsl:with-param name="content" select="'Cancel'" />
                            <xsl:with-param name="type" select="'default'"/>
                            <xsl:with-param name="className" select="'Form-button'"/>
                            <xsl:with-param name="elemType" select="'button'"/>
                            <xsl:with-param name="onClick">
                                location.href='/app/tracker?page=<xsl:value-of select="Params/page" />'
                            </xsl:with-param>
                        </xsl:call-template>

                        <xsl:call-template name="uiButton">
                            <xsl:with-param name="content" select="'Update Distribution Fee'" />
                            <xsl:with-param name="type" select="'primary'"/>
                            <xsl:with-param name="className" select="'Form-button'"/>
                            <xsl:with-param name="elemType" select="'submit'"/>
                        </xsl:call-template>

                    </fieldset>
                </fieldset>
            </div>
        </form>
        <form id="confirmBox" action="/app/tracker">
            <div class="DistributionFee-change-confirm">
                <input type="hidden" name="c" value="distributionfee" />

                <xsl:if test="Params/closed">
                    <input type="hidden" name="closed" value="1" />
                </xsl:if>

                <xsl:if test="File/DistributionFeeFormats/@size &gt; 1">
                    <input type="hidden" name="has_multiple_formats" value="{File/DistributionFeeFormats/short}" />
                </xsl:if>

                <xsl:if test="File/DistributionFeeFormats/@size = 1">
                    <input type="hidden" name="has_multiple_formats" value="" />
                </xsl:if>

                <input type="hidden" name="file" value="{File/FileID}" />
                <input type="hidden" name="redirect" value="{Params/redirect}" />
                <input type="hidden" name="page" value="{Params/page}" />
                <p>
                    <span id="streamNumbers"></span> Apply distribution fee to revenue?
                </p>

                <fieldset class="Form-fieldset Form-fieldset-buttons">
                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="content" select="'Cancel'" />
                        <xsl:with-param name="type" select="'default'"/>
                        <xsl:with-param name="className" select="'Form-button'"/>
                        <xsl:with-param name="elemType" select="'button'"/>
                        <xsl:with-param name="onClick">
                            toggleLayer('confirmBox');document.getElementById('formatChoice').style.display='block'
                        </xsl:with-param>
                    </xsl:call-template>

                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="content" select="'Update'" />
                        <xsl:with-param name="type" select="'primary'"/>
                        <xsl:with-param name="className" select="'Form-button'"/>
                        <xsl:with-param name="elemType" select="'submit'"/>
                    </xsl:call-template>

                </fieldset>
            </div>
        </form>
    </xsl:template>

</xsl:stylesheet>
