<!--                                                                  -->
<!--  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="edit_digital.xsl" />
  <xsl:include href="edit_service.xsl" />
  <xsl:include href="show.xsl" />
  <xsl:include href="show_digital.xsl" />
  
  <xsl:variable name="showAlbumPurchaseOnly">
    <xsl:choose>
        <xsl:when test="/Root/ClientTypes/ClientType[ClientTypeID = 4]/IsClientTypeFlag = 1 and ((normalize-space(/Root/Form/Product/ProductDigital/ProductID) and /Root/Form/Product/ProductDigital/ProductID &gt; 0) or not(/Root/Params/ProductID))">1</xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>  
  

  <xsl:template name="pickLayout">
    <xsl:if test="$cmd = 'show'">
      <xsl:call-template name="productShowLayout" />
    </xsl:if>
    <xsl:if test="$cmd = 'edit'">
      <xsl:call-template name="productEditLayout" />
    </xsl:if>
    <xsl:if test="$cmd = 'edit_digital'">
      <xsl:call-template name="productEditDigitalLayout" />
    </xsl:if>
    <xsl:if test="$cmd = 'edit_service'">
      <xsl:call-template name="productEditServiceLayout" />
    </xsl:if>
    <xsl:if test="$cmd = 'show_digital'">
      <xsl:call-template name="productShowDigitalLayout" />
    </xsl:if>
  </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/Product/ProductID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/Product/ProductID))">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 = 'edit_service'">
        <input name="submit" type="submit" id="submitButton" value="Update" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit_digital'">
        <input name="submitButton" type="submit" id="submitButton" onClick="collectCountries(); return false;" value="Update" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" value="Edit" onClick="javascript:location.href='product?ProductID={Form/Product/ProductID}&amp;c=edit'" />
      </xsl:when>
      <xsl:when test="$cmd = 'show_digital'">
        <input type="button" value="Edit" onClick="javascript:location.href='product?ProductID={Form/Product/ProductID}&amp;c=edit_digital'" />
      </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 = 'edit' and normalize-space(Form/Product/ProductID)">
				<!--
        <input name="deleteButton" type="button" value="Delete" onClick="confirmDeleteProduct({Form/Product/ProductID})">
          <xsl:if test="Form/Product/ProductStatusID != 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
        <xsl:if test="Form/Product/ProductStatusID != 1">
          <xsl:call-template name="helpIcon">
            <xsl:with-param name="tip">This product cannot be deleted.</xsl:with-param>
          </xsl:call-template>
        </xsl:if>
				-->
        <input type="button" value="Return to Product" onClick="location.href='/rps/product?c=show&amp;ProductID={Form/Product/ProductID}'" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit_digital' and normalize-space(Form/Product/ProductID)">
        <input type="button" value="Return to Album" onClick="location.href='catalog?AlbumID={Form/Album/AlbumID}&amp;c=show&amp;tab=distributionTab'" />
      </xsl:when>
      <xsl:when test="$cmd = 'show_digital'">
      </xsl:when>
      <xsl:otherwise>
        <input type="button" value="Return to Album">
          <xsl:attribute name="onClick">
            <xsl:choose>
              <xsl:when test="Params/_inline">hideInlinePop()</xsl:when>
              <xsl:otherwise>location.href='catalog?AlbumID=<xsl:value-of select="Form/Album/AlbumID" />&amp;c=show'</xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
        </input>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
