<!--                                                                  -->
<!--  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="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="priceEditLayout" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="priceSearchLayout" />
                </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/Price/PriceID)">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:call-template>
				<xsl:choose>
					<xsl:when test="not(normalize-space(Form/Price/PriceID))">
						<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/price?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:with-param name="disabled">
								<xsl:if test="$openRuns = 1">true</xsl:if>
							</xsl:with-param>
						</xsl:call-template>
					</xsl:when>
				</xsl:choose>
			</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='price?PriceID=<xsl:value-of select="Form/Price/PriceID" />&amp;c=edit'</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="not(Params/_inline)">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Add New Price'"/>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="onClick">javascript:location.href='price?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="name" select="'selectMatch'"/>
					<xsl:with-param name="id" select="'selectMatch'"/>
					<xsl:with-param name="disabled" select="'true'" />
					<xsl:with-param name="content">Use this <xsl:value-of select="$area" /></xsl:with-param>
					<xsl:with-param name="type" select="'primary'"/>
					<xsl:with-param name="onClick">useMatch('<xsl:value-of select="$area" />')</xsl:with-param>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="cancelButton">
		<xsl:choose>
			<xsl:when test="$cmd = 'show'">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="name" select="'Back'"/>
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Back to Prices'"/>
					<xsl:with-param name="onClick">location.href='price'</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$cmd = 'list'">
				<xsl:call-template name="uiButton">
					<xsl:with-param name="name" select="'Back'"/>
					<xsl:with-param name="className" select="'Form-button'"/>
					<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:when>
			<xsl:when test="$cmd = 'edit'">
				<xsl:choose>
					<xsl:when test="normalize-space(Form/Price/PriceID)">
						<xsl:call-template name="uiButton">
							<xsl:with-param name="className" select="'Form-button-left'"/>
							<xsl:with-param name="content" select="'Delete'"/>
							<xsl:with-param name="type" select="'danger'"/>
							<xsl:with-param name="name" select="'deleteButton'"/>
							<xsl:with-param name="disabled">
								<xsl:if test="Form/Price/InUse = 1">true</xsl:if>
							</xsl:with-param>
							<xsl:with-param name="onClick">confirmDeletePrice(<xsl:value-of select="Form/Price/PriceID"/>)</xsl:with-param>
						</xsl:call-template>
						<xsl:if test="Form/Price/InUse = 1">
							<div class="HelpText HelpText-bybutton">This price cannot be deleted because it's tied to 1 or more products</div>
						</xsl:if>
					</xsl:when>
				</xsl:choose>
				<xsl:call-template name="uiButton">
					<xsl:with-param name="name" select="'Back'"/>
					<xsl:with-param name="className" select="'Form-button'"/>
					<xsl:with-param name="content" select="'Back to Prices'"/>
					<xsl:with-param name="onClick">location.href='price'</xsl:with-param>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
