<!--                                                                  -->
<!--  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="masterEditLayout">

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

        <script type="text/javascript">
            validationSet = {
                'Form_Master_ISRC': {
                    'regexp': /^[A-Za-z]{2}[A-Z0-9]{3}[0-9]{7}$/,
                    //'errorBlank': 'Invalid ISRC.<br /> ',
                    'error': 'Invalid ISRC.<br /> '
                },
                'Form_Master_Title': {
                    'regexp': /^.*$/,
                    'errorBlank': 'Title cannot be blank.<br /> '
                }
            };

            window.validationSet = validationSet;
            fV.init();
            popValidation = 1;
            window.popValidation = popValidation;
            interceptSubmit = "collectFields('masterEdit','master');";
            window.interceptSubmit = interceptSubmit;

        </script>


    </xsl:template>

    <xsl:template name="masterEditHidden">
        <script type="text/javascript">
            fieldFocus("Form_Master_Title");
        </script>
        <input type="hidden" name="_inline" value="1" />
        <input type="hidden" name="formSubmit" value="1" />
        <input type="hidden" name="c" value="edit" />
        <xsl:if test="normalize-space(Form/Master/MasterID)">
            <input type="hidden" name="MasterID" value="{Form/Master/MasterID}" />
        </xsl:if>
        <xsl:if test="Form/Master/MasterID = ''">
            <input type="hidden" name="new" value="1" />
        </xsl:if>
    </xsl:template>

    <xsl:template name="masterEdit">
        <section class="TrackEditModal-section">
            <xsl:call-template name="errorMessageGeneral" />
            <div class="Required-notice-wrapper">
                <h4>Master</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 Master Recording information here.<br />Album tracks linked to this master are listed below.</p>
                    </div>
                </div>

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

                    <xsl:if test="Form/Master/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_Master_Title" id="Form_Master_Title" value="{Form/Master/Title}" />
                        </div>
                    </label>

                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Form/Master/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/Master/ArtistName[@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">Artist</span>
                        <div class="Form-input-wrapper">
                            <input id="Form_Master_ArtistName" name="Form_Master_ArtistName" type="text" class="Input Form-input" value="{Form/Master/ArtistName}" /><xsl:text> </xsl:text><span id="noMatchMasterArtistPop" class="yui-ac-warning"></span>
                            <input type="hidden" name="Form_Master_ArtistID" id="Form_Master_ArtistID" value="{Form/Master/ArtistID}" />
                            <div id="masterArtistContainerPop"></div>
                            <script type="text/javascript">
                                var masterArtistCompPop = new YAHOO.widget.RSArtistAutoComplete("masterArtistContainerPop","Form_Master_ArtistName", "Form_Master_ArtistID", {
                                    "noMatchWarningID": "noMatchMasterArtistPop"
                                });
                            </script>
                        </div>
                    </label>

                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Form/Master/ArtistName</xsl:with-param>
                        <xsl:with-param name="displayName">Artist Name</xsl:with-param>
                    </xsl:call-template>
                </div>

                <div class="Form-item">
                    <xsl:if test="Form/Master/ISRC[@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">ISRC</span>
                        <div class="Form-input-wrapper">
                            <input type="text" class="Input Form-input" name="Form_Master_ISRC" id="Form_Master_ISRC" value="{Form/Master/ISRC}" />
                        </div>
                    </label>

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

                <div class="Form-item">
                    <xsl:if test="Form/Master/ISRC[@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">Recording Date</span>
                        <div class="Form-input-wrapper">
                            <xsl:call-template name="uiDatepicker">
                                <xsl:with-param name="id" select="'Form_Master_DateRecorded'" />
                                <xsl:with-param name="name" select="'Form_Master_DateRecorded'" />
                                <xsl:with-param name="value">
                                    <xsl:choose>
                                        <xsl:when test="normalize-space(Form/Master/DateRecorded)">
                                            <xsl:value-of select="Form/Master/DateRecorded" />
                                        </xsl:when>
                                        <xsl:otherwise></xsl:otherwise>
                                    </xsl:choose>
                                </xsl:with-param>

                                <xsl:with-param name="iconId" select="'calendarIconMaster'" />

                                <xsl:with-param name="onClick">
                                    <xsl:text>checkDate(this);</xsl:text>
                                </xsl:with-param>
                            </xsl:call-template>
                        </div>
                    </label>
                </div>

                <div class="Form-item Form-item-required TrackEdit-field-duration">
                    <xsl:if test="Form/Master/Duration[@e]">
                        <xsl:attribute name="class">
                            <xsl:text>Form-item Form-item-required Form-item-error TrackEdit-field-duration</xsl:text>
                        </xsl:attribute>
                    </xsl:if>

                    <label class="Form-label">
                        <span class="Form-label-caption">Length</span>
                        <div class="Form-input-wrapper">
                            <input type="text" class="Input Form-input" name="Form_Master_Duration" id="Form_Master_Duration" value="{Form/Master/Duration}" />
                        </div>
                    </label>

                    <xsl:call-template name="inlineError">
                        <xsl:with-param name="path">Form/Master/Duration</xsl:with-param>
                        <xsl:with-param name="displayName">Length</xsl:with-param>
                    </xsl:call-template>
                </div>
            </fieldset>
        </section>
        <xsl:call-template name="tracksView" />

    </xsl:template>

</xsl:stylesheet>
