<!--                                                                  -->
<!--  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="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" 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">
    <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>
  </xsl:template>

  <xsl:template name="submitButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit'">
        <input name="submit" type="submit" id="submitButton">
          <xsl:attribute name="value">
            <xsl:if test="normalize-space(Form/Price/PriceID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/Price/PriceID))">Create</xsl:if>
          </xsl:attribute>
          <xsl:if test="$openRuns = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" value="Edit" onClick="javascript:location.href='price?PriceID={Form/Price/PriceID}&amp;c=edit'" />
      </xsl:when>
      <xsl:when test="not(Params/_inline)">
        <input type="button" value="Add New Price" onClick="javascript:location.href='price?c=edit'" />
      </xsl:when>
      <xsl:otherwise>
        <input type="button" name="selectMatch" id="selectMatch" value="Use this {$area}" disabled="true" onClick="useMatch('{$area}')" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="cancelButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'list'">
        <input type="button" name="Back" value="Back to Admin" onClick="location.href='/rps/display?d=config'" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit'">
        <xsl:choose>
          <xsl:when test="normalize-space(Form/Price/PriceID)">
            <input name="deleteButton" type="button" value="Delete" onClick="confirmDeletePrice({Form/Price/PriceID})">
            <xsl:if test="Form/Price/InUse = 1">
              <xsl:attribute name="disabled">disabled</xsl:attribute>
            </xsl:if>
            </input>
            <xsl:if test="Form/Price/InUse = 1">
              <xsl:call-template name="helpIcon">
                <xsl:with-param name="tip">This price cannot be deleted because it's tied to 1 or more products.</xsl:with-param>
              </xsl:call-template>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <input type="submit" id="addAnotherButton" value="Create and Add Another" onClick="modifyFieldValue('ReturnTo','/rps/price?c=edit&amp;msg=success|form_submit_success');" >
              <xsl:if test="$openRuns = 1">
                <xsl:attribute name="disabled">disabled</xsl:attribute>
              </xsl:if>
            </input>
          </xsl:otherwise>
        </xsl:choose>
        <input type="button" value="Back to Prices" onClick="location.href='price'" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" name="Back to Prices" value="Back to Prices" onClick="location.href='price'" />
      </xsl:when>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
