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

	<xsl:variable name="contractHome">
		<xsl:choose>
			<xsl:when test="/Root/Access/rps/artist_contract/main">contract</xsl:when>
			<xsl:otherwise>distributor_contract</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>	

  <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:when test="$cmd = 'main'">
        <xsl:call-template name="contractMainLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'list'">
        <xsl:call-template name="contractListLayout" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="contractSearchLayout" />
      </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/DistributorContract/DistributorContractID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/DistributorContract/DistributorContractID))">Create</xsl:if>
          </xsl:attribute>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" value="Edit Contract" onClick="javascript:location.href='distributor_contract?DistributorContractID={Form/DistributorContract/DistributorContractID}&amp;c=edit'">
          <xsl:if test="$lockedRecord = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="cancelButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit'">
        <xsl:if test="Params/DistributorContractID">
        	<input type="button" value="Return to Contract" onClick="location.href='distributor_contract?DistributorContractID={Params/DistributorContractID}&amp;c=show'" />
        </xsl:if>
        <xsl:if test="not(Params/DistributorContractID)">
        	<input type="button" value="Back to Contracts" onClick="location.href='{$contractHome}'" />
        </xsl:if>
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" value="Back to Contracts" onClick="location.href='{$contractHome}'" />
      </xsl:when>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="contractTable">
  	<xsl:param name="contract" />
    <table class="textChart hiOn">
			<xsl:call-template name="contractHeader" />
      <xsl:for-each select="$contract">
				<xsl:call-template name="distributorContractRow" />
      </xsl:for-each>  
    </table>
  </xsl:template>

  <xsl:template name="contractHeader">
    <tr>
      <th>Contract Title</th>
      <th>Label</th>
      <th>Contract ID</th>
      <th>Payor</th>
			<th>Payee</th>
      <xsl:if test="/Root/Access/rps/distributor_contract/edit">
        <th class="editCol">Edit</th>
      </xsl:if>
    </tr>
  </xsl:template>


</xsl:stylesheet>

