<!--                                                                  -->
<!--  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="show.xsl" />
	<xsl:include href="search.xsl" />
	<xsl:include href="edit.xsl" />

	<xsl:template name="pickLayout">
        <div class="MainBaseSection">
            <xsl:choose>
                <xsl:when test="$cmd = 'edit'">
                    <xsl:call-template name="labelEditLayout" />
                </xsl:when>
                <xsl:when test="$cmd = 'show'">
                    <xsl:call-template name="labelViewLayout" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="labelListLayout" />
                </xsl:otherwise>
            </xsl:choose>
        </div>
	</xsl:template>

	<xsl:template name="submitButton">
		<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">
						<xsl:choose>
							<xsl:when test="normalize-space(Form/Label/LabelID)">Update</xsl:when>
							<xsl:otherwise>Create</xsl:otherwise>
						</xsl:choose>
					</xsl:with-param>
					<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="'submitButton'"/>
					<xsl:with-param name="disabled">
						<xsl:if test="$openRuns = 1">true</xsl:if>
					</xsl:with-param>
					<xsl:with-param name="onClick">selectAllMulti('Form_Label_UserID');</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$cmd = 'show'">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Edit'"/>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="onClick">javascript:location.href='label?LabelID=<xsl:value-of select="Form/Label/LabelID" />&amp;c=edit'</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="content" select="'Add New Label'"/>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="onClick">javascript:location.href='label?c=edit'</xsl:with-param>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
  	</xsl:template>

	<xsl:template name="cancelButton">
		<xsl:choose>
		<xsl:when test="$cmd = 'edit' and normalize-space(Form/Label/LabelID)">
			<xsl:call-template name="uiButton">
				<xsl:with-param name="className" select="'Form-button'"/>
				<xsl:with-param name="content" select="'Return to Label'"/>
				<xsl:with-param name="onClick">location.href='label?LabelID=<xsl:value-of select="Params/LabelID"/>&amp;c=show'</xsl:with-param>
			</xsl:call-template>
		</xsl:when>
		<xsl:when test="$cmd = 'edit' and not(normalize-space(Form/Label/LabelID))">
			<xsl:call-template name="uiButton">
				<xsl:with-param name="className" select="'Form-button'"/>
				<xsl:with-param name="content" select="'Create and Add Another'"/>
				<xsl:with-param name="type" select="'primary'"/>
				<xsl:with-param name="onClick">modifyFieldValue('ReturnTo','/rps/label?c=edit&amp;msg=success|form_submit_success');</xsl:with-param>
				<xsl:with-param name="name" select="'submitButton'"/>
				<xsl:with-param name="id" select="'addAnotherButton'"/>
				<xsl:with-param name="elemType" select="'submit'"/>
			</xsl:call-template>
			<xsl:call-template name="uiButton">
				<xsl:with-param name="className" select="'Form-button'"/>
				<xsl:with-param name="content" select="'Back to Labels'"/>
				<xsl:with-param name="onClick">location.href='/rps/label'</xsl:with-param>
			</xsl:call-template>
		</xsl:when>
		<xsl:when test="$cmd = 'show'">
			<xsl:call-template name="uiButton">
				<xsl:with-param name="className" select="'Form-button'"/>
				<xsl:with-param name="content" select="'Back to Labels'"/>
				<xsl:with-param name="onClick">location.href='/rps/label'</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="'Back'"/>
						<xsl:with-param name="content" select="'Back to Admin'"/>
						<xsl:with-param name="onClick">location.href='/rps/display?d=config'</xsl:with-param>
					</xsl:call-template>
				</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
