<!--                                                                  -->
<!--  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="show.xsl" />
	<xsl:include href="show_contracts.xsl" />
	<xsl:include href="show_licenses.xsl" />
  <xsl:include href="search.xsl" />
  <xsl:include href="edit.xsl" />
  <xsl:include href="da_edit.xsl" />
	<xsl:include href="da_show.xsl" />
	<xsl:include href="list.xsl" />
  <xsl:include href="main.xsl" />
  <xsl:include href="../shared_layouts/expense.xsl" />
  <xsl:include href="../shared_layouts/expense_edit.xsl" />
  <xsl:include href="../shared_layouts/advance.xsl" />

	<xsl:variable name="daTest" />

  <xsl:variable name="contractName">AlbumContractID</xsl:variable>
  <xsl:variable name="contractID"><xsl:value-of select="/Root/Params/AlbumContractID" /></xsl:variable>

  <xsl:template name="pickLayout">

    <script type="text/javascript" src="/production/javascript/catalog.js"></script>

    <xsl:choose>
      <xsl:when test="$cmd = 'advance'">
        <xsl:call-template name="advanceLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'expense'">
        <xsl:call-template name="expenseLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'expense_edit'">
        <xsl:call-template name="expenseEditLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit'">
        <xsl:call-template name="catalogEditLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'da_edit'">
        <xsl:call-template name="catalogDaEditLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'da_show'">
        <xsl:call-template name="catalogDaViewLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'list'">
        <xsl:call-template name="catalogListLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'main'">
        <xsl:call-template name="catalogMainLayout" />
      </xsl:when>

      <xsl:when test="$cmd = 'show'">
          <xsl:call-template name="catalogViewLayout" />
      </xsl:when>

      <xsl:when test="$cmd = 'show_contracts'">
          <xsl:call-template name="catalogContractViewLayout" />
      </xsl:when>

      <xsl:when test="$cmd = 'show_licenses'">
          <xsl:call-template name="catalogLicenseViewLayout" />
      </xsl:when>

      <xsl:otherwise>
        <xsl:call-template name="catalogSearchLayout" />
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>


  <xsl:template name="submitButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'advance'">
        <input name="submit" type="submit" id="submitButton">
          <xsl:attribute name="value">
            <xsl:if test="normalize-space(//AdvanceAccount/AccountID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(//AdvanceAccount/AccountID))">Create</xsl:if>
          </xsl:attribute>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'edit'">
        <input name="submitButton" type="submit" id="submitButton">
          <xsl:if test="$openRuns = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
          <xsl:attribute name="value">
            <xsl:if test="normalize-space(Form/Album/AlbumID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/Album/AlbumID))">Create</xsl:if>
          </xsl:attribute>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'da_edit'">
        <input name="submitButton" type="submit" id="submitButton">
          <xsl:attribute name="value">
            <xsl:if test="normalize-space(Form/Album/AlbumID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/Album/AlbumID))">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 = 'expense_edit'">
        <input name="submit" type="submit" id="submitButton">
          <xsl:attribute name="value">
            <xsl:if test="normalize-space(Form/Expense/ExpenseID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/Expense/ExpenseID))">Create</xsl:if>
          </xsl:attribute>
          <xsl:if test="$openRuns = 1 or ((Form/DefaultTerm = 1 or Form/DefaultTerm = 3) and (/Root/Params/PreProcess = 1 or Form/Expense/PreProcess = 1))">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'da_show' and Access/rps/catalog/da_edit">
	    	<input type="button" value="Edit Album" onClick="location.href='catalog?c=da_edit&amp;AlbumID={Form/Album/AlbumID}'" />
			</xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="class" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <xsl:template name="cancelButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'advance' or $cmd = 'expense'">
        <input type="button" name="Back" value="Return to Contract" onClick="location.href='artist_contract?ArtistContractID={Form/AlbumContract/ContractID}&amp;c=show'" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit' and normalize-space(Form/Album/AlbumID)">
        <input type="button" name="Cancel" value="Return to Album" onClick="location.href='catalog?AlbumID={Form/Album/AlbumID}&amp;c=show'" />
      </xsl:when>
      <xsl:when test="$cmd = 'da_edit' and normalize-space(Form/Album/AlbumID)">
        <input type="button" name="Cancel" value="Return to Album" onClick="location.href='catalog?AlbumID={Form/Album/AlbumID}&amp;c=show'" />
      </xsl:when>
      <xsl:when test="$cmd = 'expense_edit'">
        <xsl:if test="normalize-space(Form/Expense/ExpenseID)">
          <input type="button" name="Delete" value="Delete" onClick="confirmDeleteExpense({Form/Expense/ExpenseID},'catalog','{$pageName}')" >
            <xsl:if test="$openRuns = 1">
              <xsl:attribute name="disabled">disabled</xsl:attribute>
            </xsl:if>
		  </input>
        </xsl:if>
        <input type="button" name="Back" value="Return to Expense List" onClick="location.href='catalog?AlbumContractID={Params/AlbumContractID}&amp;c=expense'" />
      </xsl:when>
      <xsl:otherwise>
        <input type="button" value="Back to Albums" onClick="location.href='catalog'" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


</xsl:stylesheet>
