<!--                                                                  -->
<!--  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:output method="html" indent="no" doctype-system="" encoding="utf-8" />

    <xsl:include href="/app/tools/rps/templates/global.xsl" />
    <xsl:include href="edit.xsl" />
    <xsl:include href="show.xsl" />
    <xsl:include href="search.xsl" />

    <xsl:template name="pickLayout">
        <xsl:choose>
            <xsl:when test="$cmd = 'edit'">
                <xsl:call-template name="songEditLayout" />
            </xsl:when>
            <xsl:when test="$cmd = 'show'">
                <xsl:call-template name="songViewLayout" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="songSearchLayout" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="submitButton">
        <xsl:choose>
            <xsl:when test="$cmd = 'edit'">
                <xsl:call-template name="uiButton">
                    <xsl:with-param name="type" select="'primary'" />
                    <xsl:with-param name="elemType" select="'submit'" />
                    <xsl:with-param name="name" select="'submit'" />
                    <xsl:with-param name="id" select="'popSubmitButton'" />
                    <xsl:with-param name="className" select="'Form-button'" />
                    <xsl:with-param name="content">
                        <xsl:if test="normalize-space(Form/Song/SongID)">Update</xsl:if>
                        <xsl:if test="not(normalize-space(Form/Song/SongID))">Create</xsl:if>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$cmd = 'show'">

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="type" select="'primary'" />
                    <xsl:with-param name="className" select="'Form-button'" />
                    <xsl:with-param name="content" select="'Edit'" />
                    <xsl:with-param name="url">
                        <xsl:text>song?SongID=</xsl:text>
                        <xsl:value-of select="Form/Song/SongID" />
                        <xsl:text>&amp;c=edit</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>

            </xsl:when>
            <xsl:otherwise>

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="type" select="'primary'" />
                    <xsl:with-param name="name" select="'selectMatch'" />
                    <xsl:with-param name="id" select="'selectMatch'" />
                    <xsl:with-param name="className" select="'Form-button'" />
                    <xsl:with-param name="disabled" select="'true'" />
                    <xsl:with-param name="content">
                        <xsl:text>Use this </xsl:text>
                        <xsl:value-of select="$area" />
                    </xsl:with-param>
                    <xsl:with-param name="onClick">
                        <xsl:text>modifyField('selectMatch','disable'); useMatch('</xsl:text>
                        <xsl:value-of select="$area" />
                        <xsl:text>')</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>

            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="cancelButton">
        <xsl:choose>
            <xsl:when test="$cmd = 'edit'">

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="className" select="'Form-button'" />
                    <xsl:with-param name="content" select="'Cancel'" />
                    <xsl:with-param name="onClick">
                        <xsl:choose>
                            <xsl:when test="Params/_inline">hideInlinePop()</xsl:when>
                            <xsl:otherwise>javascript:history.go(-1)</xsl:otherwise>
                        </xsl:choose>
                    </xsl:with-param>
                </xsl:call-template>

            </xsl:when>
            <xsl:when test="$cmd = 'show'">

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="name" select="'Delete'" />
                    <xsl:with-param name="className" select="'Form-button'" />
                    <xsl:with-param name="content" select="'Delete'" />
                    <xsl:with-param name="onClick">
                        alert('This doesn\'t work yet')
                    </xsl:with-param>
                </xsl:call-template>

            </xsl:when>
            <xsl:otherwise>

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="className" select="'Form-button'" />
                    <xsl:with-param name="name" select="'Cancel'" />
                    <xsl:with-param name="content" select="'Cancel'" />
                    <xsl:with-param name="onClick">
                        hideInlinePop()
                    </xsl:with-param>
                </xsl:call-template>

            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

</xsl:stylesheet>

