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

  <xsl:template name="pickLayout">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit'">
        <xsl:call-template name="contractEditLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <xsl:call-template name="contractShowLayout" />
      </xsl:when>
    </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/ArtistContract/ArtistContractID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/ArtistContract/ArtistContractID))">Create</xsl:if>
          </xsl:attribute>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" value="Edit Contract" onClick="javascript:location.href='contract?ContractID={Form/ArtistContract/ArtistContractID}&amp;c=edit'">
          <xsl:if test="$lockedRecord = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'term' or $cmd = 'region' or $cmd = 'deduction' or $cmd = 'unit_escalation' or $cmd = 'expense'">
        <input name="submitForm" type="submit" value="Update" id="submitButton" />
      </xsl:when>
      <xsl:otherwise>
        <input type="hidden" name="ContractID" id="ContractID" />
        <input type="button" name="selectMatch" id="selectMatch" value="Use this {$area}" disabled="true">
          <xsl:attribute name="onClick">
            <xsl:if test="Params/AlbumID">attachContract('catalog',<xsl:value-of select="Params/AlbumID" />); modifyField('selectMatch','disable');</xsl:if>
            <xsl:if test="Params/TrackID">attachContract('track',<xsl:value-of select="Params/TrackID" />); modifyField('selectMatch','disable');</xsl:if>
          </xsl:attribute>
        </input>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="cancelButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit' and Params/_inline">
        <input type="button" value="Cancel" onClick="hideInlinePop()" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit' and not(Params/_inline)">
        <xsl:if test="Params/ContractID">
        <input type="button" value="Return to Contract" onClick="location.href='contract?ContractID={Params/ContractID}&amp;c=show'" />
        </xsl:if>
        <xsl:if test="not(Params/ContractID)">
        <input type="button" value="Back to Contracts" onClick="location.href='contract'" />
        </xsl:if>
      </xsl:when>
      <xsl:when test="$cmd = 'term' or $cmd = 'region' or $cmd = 'deduction' or $cmd = 'unit_escalation' or $cmd = 'expense'">
        <input type="button" name="Back" value="Return to Contract" onClick="location.href='contract?ContractID={Form/ArtistContract/ArtistContractID}&amp;c=show'" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" value="Back to Contracts" onClick="location.href='contract'" />
      </xsl:when>
      <xsl:when test="$cmd = 'search' and Params/_inline">
        <input type="button" name="Cancel" value="Cancel" onClick="hideInlinePop()" />
      </xsl:when>
      <xsl:otherwise>
        <input type="button" name="Cancel" value="Return to Album" onClick="location.href='catalog?AlbumID={Params/AlbumID}&amp;c=show'" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

