<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--                                                                  -->
<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:variable name="productType" select="/Root/Form/TypeList/Type[ProductTypeID = /Root/Form/Product/ProductTypeID]/Type" />

  <xsl:template name="productShowLayout">
    <div class="section">
      <xsl:call-template name="successMessageGeneral">
        <xsl:with-param name="successMessage">Product successfully updated!</xsl:with-param>
      </xsl:call-template>
      <xsl:call-template name="albumView" />
      <br />
      <xsl:call-template name="productShow" />
      <br />
	  <xsl:call-template name="priceShow" />
	  <br />
      <xsl:call-template name="trackListShow" />
      <br /><br />
    </div>
    <xsl:call-template name="buttons" />
  </xsl:template>

  <xsl:template name="productShow">
    <fieldset>
      <legend>Product</legend>
      <div class="insideFieldset">
        <xsl:call-template name="column1Show" />
        <xsl:call-template name="column2Show" />
      </div>
    </fieldset>
  </xsl:template>

  <xsl:template name="column1Show">
    <div class="column1">
      <table>
        <tr>
          <td class="leftCol"><label for="Form_Product_ProductTypeID">Type:</label></td>
          <td><xsl:value-of select="Form/TypeList/Type[ProductTypeID = /Root/Form/Product/ProductTypeID]/Description" /></td>
        </tr>
        <tr>
          <td class="leftCol" style="vertical-align: top"><label for="Form_Product_Title">Product Title:</label></td>
          <td style="padding-top: 9px">
            <xsl:value-of select="Form/Product/Title" />
          </td>
        </tr>        
        <tr>
          <td class="leftCol"><label for="Form_Product_ProductID">Product ID:</label></td>
          <td>
            <xsl:value-of select="Form/Product/ProductCode" />
          </td>
        </tr>
      </table>
    </div>
  </xsl:template>

  <xsl:template name="column2Show">
    <div class="column2">
      <table>
        <tr>
          <td class="leftCol"><label for="Form_Product_UPC">UPC:</label></td>
          <td>
            <xsl:value-of select="Form/Product/UPC" />
          </td>
        </tr>        
        <tr>
          <td class="leftCol"><label for="Form_Product_ReleaseDate">Release Date:</label></td>
          <td><xsl:value-of select="Form/Product/ReleaseDate" /></td>
        </tr>
        <tr>
          <td class="leftCol"><label for="Form_Product_ProductStatusID">Status:</label></td>
          <td>
            <xsl:for-each select="Form/StatusList/Status[ProductStatusID = /Root/Form/Product/ProductStatusID]">
              <xsl:value-of select="Description" />
            </xsl:for-each>
          </td>
        </tr>
        
        <xsl:if test="ClientTypes/ClientType[ClientTypeID = 6]/IsClientTypeFlag = 1">
            <tr>
                <td class="leftCol">Deleted:</td>
                <td>
                    <xsl:choose>
                        <xsl:when test="Form/Product/Deleted = 0">
                            No
                        </xsl:when>
                        <xsl:otherwise>
                            Yes&#160;&#160;<strong>Deletion Date:</strong>&#160;<xsl:value-of select="Form/Product/DeletedDate" />
    		          </xsl:otherwise>
    	          </xsl:choose>
              </td>
            </tr>    
        </xsl:if>    
        
      </table>
    </div>
  </xsl:template>

  <xsl:template name="priceShow">
    <fieldset>
      <legend>Prices</legend>
      <xsl:variable name="priceTest">
        <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = $productType]">
          <xsl:variable name="priceLevelID" select="PriceLevelID" />
          <xsl:for-each select="/Root/Form/Product/PriceList/Price[PriceLevelID = $priceLevelID]">
            <xsl:value-of select="PriceID" />
          </xsl:for-each>
        </xsl:for-each>
      </xsl:variable>
      <xsl:choose>
        <xsl:when test="normalize-space($priceTest)">
          <div class="column1">
            <table>
              <xsl:choose>
                <xsl:when test="Form/TypeList/Type[ProductTypeID = /Root/Form/Product/ProductTypeID]/Type = 1">
                  <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 1]">
                    <xsl:call-template name="priceLevelRowShow" />
                  </xsl:for-each>
                  <tr>
                    <td class="leftCol"><label for="Form_Product_DefaultPriceLevelID">Default:</label></td>
                    <td>
                      <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 1]">
                        <xsl:if test="PriceLevelID = /Root/Form/Product/DefaultPriceLevelID">
                          <xsl:value-of select="Name" />
                        </xsl:if>
                      </xsl:for-each>
                    </td>
                  </tr>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type != 1]">
                    <xsl:call-template name="priceLevelRowShow" />
                  </xsl:for-each>
                </xsl:otherwise>
              </xsl:choose>
            </table>
          </div>
        </xsl:when>
        <xsl:otherwise>
          <div class="insideFieldset">
            No price information has been entered.
          </div>
        </xsl:otherwise>
      </xsl:choose>
    </fieldset>
  </xsl:template>

  <xsl:template name="priceLevelRowShow">
    <xsl:variable name="priceLevelID" select="PriceLevelID" />
    <xsl:if test="normalize-space(/Root/Form/Product/PriceList/Price[PriceLevelID = $priceLevelID]/ProductPriceID)">
      <tr>
        <td class="leftCol"><label for="Form_Product_PriceList_Price_{@i}_PriceID"><xsl:value-of select="Name" />:</label></td>
        <td>
          <xsl:for-each select="/Root/Form/PriceList/Price">
            <xsl:if test="PriceID = /Root/Form/Product/PriceList/Price[PriceLevelID = $priceLevelID]/PriceID">
              <xsl:call-template name="formatDollars">
                <xsl:with-param name="dollarAmount" select="Retail" />
              </xsl:call-template>
            </xsl:if>
          </xsl:for-each>
        </td>
      </tr>
    </xsl:if>
  </xsl:template>

    <xsl:template name="trackListShow">
        <xsl:variable name="includedTracks" select="count(/Root/Form/Product/TrackList/Track[Included = 1])" />
        <fieldset id="productTrackTableShow">
            <legend>Tracks</legend>
            <xsl:choose>
                <xsl:when test="$includedTracks &gt; 0">
                    <table class="textChart">
                        <tbody>                
                            <tr>
                                <th id="trackIncl">Status</th>
                                <xsl:if test="$showAlbumPurchaseOnly = 1">
                                    <th id="trackAlbumOnly" class="status">Album Purchase Only</th>
                    	        </xsl:if>
                                <th id="trackNum">Track</th>
                                <th id="trackName">Name</th>
                                <th id="trackLength">Length</th>
                                <th>Media Type</th>
                                <th id="discNum">Disc #</th>
                                <th id="discTrack">Disc Track</th>
                            </tr>
                            <xsl:for-each select="/Root/Form/Product/TrackList/Track[Included = 1]">
                                <xsl:call-template name="trackListShowRow" />
                            </xsl:for-each>
                        </tbody>
                    </table>
                </xsl:when>
                <xsl:otherwise>
                    <div class="insideFieldset">
                        No tracks have been included for this product.
                    </div>
                </xsl:otherwise>
              </xsl:choose>          
        </fieldset>
    </xsl:template>

  <xsl:template name="trackListShowRow">
    <xsl:variable name="trackID" select="TrackID" />
    <tr class="row{position() mod 2}">
      <td class="trackStatus">
        <xsl:if test="Included = 1 and IsBonusTrack != 1">Included</xsl:if>
        <xsl:if test="IsBonusTrack = 1">Bonus</xsl:if>
      </td>
      <xsl:if test="$showAlbumPurchaseOnly = 1">
	    <td class="status">
		  <xsl:choose>
		    <xsl:when test="AlbumOnly &gt; 0">Yes</xsl:when>
		    <xsl:otherwise>No</xsl:otherwise>
  		   </xsl:choose>
	    </td>
	  </xsl:if>
      <td class="trackNumber"><xsl:if test="TrackOrder &lt; 10">0</xsl:if><xsl:value-of select="TrackOrder" /></td>
      <td class="trackTitle"><xsl:value-of select="Title" /></td>
      <td class="length"><xsl:value-of select="Duration" /></td>
      <td>
          <xsl:choose>
            <xsl:when test="MediaType = 2">Video</xsl:when>
          	<xsl:otherwise>Audio</xsl:otherwise>
          </xsl:choose>
      </td>
      <td><xsl:value-of select="DiscNumber" /></td>
      <td><xsl:value-of select="DiscTrack" /></td>
    </tr>
    <xsl:if test="IsBonusTrack = 1">
        <tr class="row{position() mod 2}" id="bonus{@i}">
          <td class="servicesShow" colspan="7">
            <xsl:if test="/Root/Form/Product/ProductDigital/ProductID &gt; 0">
                <xsl:attribute name="colspan">8</xsl:attribute>
            </xsl:if>
            <strong>Services:</strong><xsl:text> </xsl:text>
            <span id="serviceList_{@i}">
              <xsl:variable name="serviceTest">
                <xsl:for-each select="BonusTrackList/BonusTrack">
                  <xsl:if test="normalize-space(ServiceID)"><xsl:value-of select="ServiceID" /></xsl:if>
                </xsl:for-each>
              </xsl:variable>
              <xsl:choose>
                <xsl:when test="normalize-space($serviceTest)">
                  <xsl:for-each select="BonusTrackList/BonusTrack">
                     <xsl:sort select="ServiceName" />
                     <xsl:variable name="serviceID" select="ServiceID" />
                    <xsl:if test="position() != 1">, </xsl:if>
                    <xsl:value-of select="/Root/Form/ServiceList/Service[ServiceID = $serviceID]/ServiceName" />
                  </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>None</xsl:otherwise>
              </xsl:choose>
            </span>
          </td>
        </tr>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>
