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

    <xsl:template name="songEditLayout">

        <form name="songEdit" id="songEdit" method="post">
            <xsl:choose>
                <xsl:when test="Params/_inline">
                    <xsl:attribute name="action">#</xsl:attribute>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:attribute name="action">song</xsl:attribute>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:call-template name="songEdit" />
            <xsl:call-template name="buttons" />
            <xsl:call-template name="songEditHidden" />
        </form>

        <script type="text/javascript">
            validationSet = {
                'Form_Song_Title': {
                'regexp': /^.*$/,
                'errorBlank': 'Title cannot be blank.<br /> '
                }
            };
            window.validationSet = validationSet;
            fV.init();
            popValidation = 1;
            window.popValidation = popValidation;
            interceptSubmit = "collectFields('songEdit','song');";
            window.interceptSubmit = interceptSubmit;
        </script>

    </xsl:template>

    <xsl:template name="songEditHidden">
        <xsl:if test="Params/_inline">
            <script type="text/javascript">
                fieldFocus("Form_Song_Title");
            </script>
            <input type="hidden" name="_inline" value="1" />
        </xsl:if>
        <input type="hidden" name="formSubmit" value="1" />
        <input type="hidden" name="c" value="edit" />
        <xsl:if test="normalize-space(Form/Song/SongID)">
            <input type="hidden" name="SongID" value="{Form/Song/SongID}" />
        </xsl:if>
        <xsl:if test="Form/SongID = ''">
            <input type="hidden" name="new" value="1" />
        </xsl:if>
    </xsl:template>

    <xsl:template name="songEdit">
        <section class="TrackEditModal-section">
            <xsl:call-template name="errorMessageGeneral" />
            <div class="Required-notice-wrapper">
                <h4>Song</h4>
                <div class="Required-notice" />
            </div>
            <fieldset class="Form-fieldset Form-fieldset-standart">
                <div class="Form-header">
                    <div class="Form-header-wrapper Form-header-wrapper-text">
                        <p class="Form-header-text">Enter Song information here.<br />Master recordings linked to this song are listed below.</p>
                    </div>
                </div>

                <div class="Form-item Form-item-required">

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

                    <label class="Form-label">
                        <span class="Form-label-caption">Title</span>
                        <div class="Form-input-wrapper">
                            <input type="text" class="Input Form-input" name="Form_Song_Title" id="Form_Song_Title" value="{Form/Song/Title}" />
                        </div>
                    </label>

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

                <div class="Form-item">

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

                    <label class="Form-label">
                        <span class="Form-label-caption">Composer</span>
                        <div class="Form-input-wrapper">
                            <input id="Form_Song_ComposerName" name="Form_Song_ComposerName" type="text" class="Input Form-input" value="{Form/Song/ComposerName}" /><xsl:text> </xsl:text><span id="noMatchComposerPop" class="yui-ac-warning"></span>
                            <input type="hidden" name="Form_Song_ComposerID" id="Form_Song_ComposerID" value="{Form/Song/ComposerID}" />
                            <div id="composerContainerPop"></div>
                            <script type="text/javascript">
                                new rsAutoCompleteNew({
                                    url: "/rps/catalog?c=search_composer&amp;limit=10",
                                    targetInputName: "Form_Song_ComposerName",
                                    targetInputID: "Form_Song_ComposerID",
                                    noMatchItem: "noMatchComposerPop",
                                    blockName: "Composer",
                                    itemName: "Name",
                                    itemID: "ComposerID",
                                }).init();
                            </script>
                        </div>
                    </label>

                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Form/Song/ComposerName</xsl:with-param>
                        <xsl:with-param name="displayName">Composer</xsl:with-param>
                    </xsl:call-template>
                </div>

                <div class="Form-item">

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

                    <label class="Form-label">
                        <span class="Form-label-caption">ISWC</span>
                        <div class="Form-input-wrapper">
                            <input type="text" class="Input Form-input" name="Form_Song_ISWC" id="Form_Song_ISWC" value="{Form/Song/ISWC}" />
                        </div>
                    </label>

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

            </fieldset>
        </section>
        <xsl:call-template name="mastersView" />
    </xsl:template>

</xsl:stylesheet>

