<!--                                                                  -->
<!--  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="formatType">
        <xsl:for-each select="/Root/Form/TypeList/Type">
            <xsl:if test="ProductTypeID = /Root/Form/Product/ProductTypeID"><xsl:value-of select="Type" /></xsl:if>
        </xsl:for-each>
    </xsl:variable>


    <xsl:variable name="isPhysical">
        <xsl:choose>
            <xsl:when test="/Root/Form/TypeList/Type[ProductTypeID = /Root/Form/Product/ProductTypeID]/Type = 1">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>


    <xsl:template name="productEditLayout">
        <script src="/production/javascript/validateProduct.js?v=5" type="text/javascript"></script>
        <form action="/rps/product" name="productEdit" id="productEdit" method="post">
            <input type="hidden" name="formSubmit" value="1" />
            <input type="hidden" name="c" value="edit" />
            <xsl:call-template name="productEdit" />
            <xsl:call-template name="buttons" />
        </form>
	    <xsl:call-template name="calendar">
		    <xsl:with-param name="fieldID">Form_Product_ReleaseDate</xsl:with-param>
		    <xsl:with-param name="buttonID">calendarIcon</xsl:with-param>
	    </xsl:call-template>
    </xsl:template>


    <xsl:template name="productEdit">
        <xsl:if test="normalize-space(Form/Album/AlbumID)">
            <input type="hidden" name="AlbumID" value="{Form/Album/AlbumID}" />
        </xsl:if>
        <xsl:if test="normalize-space(Form/Product/ProductID)">
            <input type="hidden" name="ProductID" value="{Form/Product/ProductID}" />
        </xsl:if>
  	    <xsl:if test="Params/show_errors">
  		    <input type="hidden" name="show_errors" value="1" />
  	    </xsl:if>
        <div class="section">
            <xsl:call-template name="albumView" />
            <br />
			<xsl:call-template name="openRunStatusMessage" />
            <xsl:call-template name="errorMessageGeneral" />
            <xsl:call-template name="productInfo" />
            <br />
	        <xsl:call-template name="priceInfo" />
	        <br />
            <xsl:call-template name="servicesHash" />
            <xsl:call-template name="trackList" />
            <br /><br />
        </div>
    </xsl:template>


  <xsl:template name="productInfo">
    <fieldset>
      <legend>Product</legend>
      <p class="formHeader">Enter product information here.</p>
      <hr />
      <div class="insideFieldset">
        <xsl:call-template name="column1Edit" />
        <xsl:call-template name="column2Edit" />
      </div>
    </fieldset>
  </xsl:template>

  <xsl:template name="column1Edit">
    <div class="column1">
      <table>
        <script type="text/javascript">
          //setting up product type id/type id hash
          var typeCollection = new Object();
          <xsl:for-each select="Form/TypeList/Type">
            typeCollection[<xsl:value-of select="ProductTypeID" />] = <xsl:value-of select="Type" />;
          </xsl:for-each>
          //setting up an array of all possible types
          var typeList = new Array();
          <xsl:for-each select="Form/TypeList/Type">
            typeList[<xsl:value-of select="@i" />] = <xsl:value-of select="Type" />;
          </xsl:for-each>
          //setting up an array of all price levels
          var levelList = new Array();
          <xsl:for-each select="Form/PriceLevelList/PriceLevel">
            levelList[<xsl:value-of select="@i" />] = <xsl:value-of select="PriceLevelID" />;
          </xsl:for-each>
          //setting up level id/name hash
          var levelNames = new Object();
          <xsl:for-each select="Form/PriceLevelList/PriceLevel">
            levelNames[<xsl:value-of select="PriceLevelID" />] = '<xsl:value-of select="Name" />';
          </xsl:for-each>
        </script>
        <tr>
          <td class="leftCol"><label for="Form_Product_ProductTypeID">*Type:</label></td>
          <td>
            <xsl:call-template name="inlineError">
              <xsl:with-param name="path">Form/Product/ProductTypeID</xsl:with-param>
              <xsl:with-param name="displayName">Type</xsl:with-param>
            </xsl:call-template>

            <select name="Form_Product_ProductTypeID" id="Form_Product_ProductTypeID" onChange="updatePriceFields(typeCollection[this.value]); updateAlbumOnly(this.value); restrictBonusTracks(this.value, {count(Form/Product/TrackList/Track)})">
    		  <xsl:if test="(normalize-space(Form/Product/ProductID) and normalize-space(Form/Product/ProductTypeID) and Form/Product/ProductTypeID != 0) or $openRuns = 1">
    		     <xsl:attribute name="disabled">disabled</xsl:attribute>
    		  </xsl:if>
              <option value="">Choose...</option>
              <xsl:for-each select="Form/TypeList/Type[ProductTypeID != 15]">
                <option value="{ProductTypeID}">
                  <xsl:if test="ProductTypeID = /Root/Form/Product/ProductTypeID">
                    <xsl:attribute name="selected">selected</xsl:attribute>
                  </xsl:if>
                  <xsl:value-of select="Description" />
                </option>
              </xsl:for-each>
            </select>
          </td>
        </tr>
        
		<tr>
			<td class="leftCol"><label for="Form_Product_Title">*Product Title:</label></td>
			<td>
				<xsl:call-template name="inlineError">
					<xsl:with-param name="path">Form/Product/Title</xsl:with-param>
					<xsl:with-param name="displayName">Product Title</xsl:with-param>
				</xsl:call-template>
				<input type="text" class="titleField" name="Form_Product_Title" id="Form_Product_Title" value="{Form/Product/Title}" >
                  <xsl:if test="$openRuns = 1">
                    <xsl:attribute name="disabled">disabled</xsl:attribute>
                  </xsl:if>
                </input>
			</td>
		</tr>                
        
        <tr>
          <td class="leftCol"><label for="Form_Product_ProductID">Product ID:</label></td>
          <td>
            <xsl:call-template name="inlineError">
              <xsl:with-param name="path">Form/Product/ProductCode</xsl:with-param>
              <xsl:with-param name="displayName">Product ID</xsl:with-param>
            </xsl:call-template>
            <input type="text" class="productIDField" name="Form_Product_ProductCode" id="Form_Product_ProductCode" value="{Form/Product/ProductCode}">
                <xsl:if test="$openRuns = 1">
                    <xsl:attribute name="disabled" select="'disabled'" />
                </xsl:if>
            </input>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <br />*Required field
          </td>
        </tr>
      </table>
    </div>
  </xsl:template>

  <xsl:template name="column2Edit">
    <div class="column2">
      <table>
        <tr>
          <td class="leftCol"><label for="Form_Product_UPC">*UPC</label></td>
          <td>
            <xsl:call-template name="inlineError">
              <xsl:with-param name="path">Form/Product/UPC</xsl:with-param>
              <xsl:with-param name="displayName">UPC</xsl:with-param>
            </xsl:call-template>
            <input type="text" class="upcField" name="Form_Product_UPC" id="Form_Product_UPC" value="{Form/Product/UPC}">
                <xsl:if test="$openRuns = 1">
                    <xsl:attribute name="disabled" select="'disabled'" />
                </xsl:if>
            </input>
          </td>
        </tr>        
        <tr>
          <td class="leftCol"><label for="Form_Product_ReleaseDate">Release Date:</label></td>
          <td>
            <xsl:call-template name="inlineError">
              <xsl:with-param name="path">Form/Product/ReleaseDate</xsl:with-param>
              <xsl:with-param name="displayName">Release Date</xsl:with-param>
            </xsl:call-template>
            <input type="text" class="dateField" name="Form_Product_ReleaseDate" id="Form_Product_ReleaseDate">
                <xsl:if test="$openRuns = 1">
                    <xsl:attribute name="disabled" select="'disabled'" />
                </xsl:if>
              <xsl:attribute name="value">
                <xsl:choose>
                  <xsl:when test="normalize-space(Form/Product/ReleaseDate)">
                    <xsl:value-of select="Form/Product/ReleaseDate" />
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="Form/TodaysDate" />
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
            </input>
            <xsl:if test="$openRuns = 0">
                <a title="Select Release Date">
                  <img src="/production/images/icons/office/Calendar-(16x16).gif" height="16" width="16" id="calendarIcon" class="calendarIcon" />
                </a>
            </xsl:if>
          </td>
        </tr>
        <tr>
          <td class="leftCol"><label for="Form_Product_ProductStatusID">Status:</label></td>
          <td>
            <xsl:call-template name="inlineError">
              <xsl:with-param name="path">Form/Product/ProductStatusID</xsl:with-param>
              <xsl:with-param name="displayName">Status</xsl:with-param>
            </xsl:call-template>
            <select name="Form_Product_ProductStatusID">
                <xsl:if test="$openRuns = 1">
                    <xsl:attribute name="disabled" select="'disabled'" />
                </xsl:if>
              <xsl:for-each select="Form/StatusList/Status">
                <option value="{ProductStatusID}">
                  <xsl:if test="ProductStatusID = /Root/Form/Product/ProductStatusID">
                    <xsl:attribute name="selected">selected</xsl:attribute>
                  </xsl:if>
                  <xsl:value-of select="Description" />
                </option>
              </xsl:for-each>
            </select>
          </td>
        </tr>

        <xsl:if test="ClientTypes/ClientType[ClientTypeID = 6]/IsClientTypeFlag = 1">
            <tr>
              <td class="leftCol"><label for="Form_Product_Deleted">Deleted:</label></td>
              <td>
                <xsl:call-template name="inlineError">
                  <xsl:with-param name="path">Form/Product/Deleted</xsl:with-param>
                  <xsl:with-param name="displayName">Deleted</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="inlineError">
                    <xsl:with-param name="path">Form/Product/DeletedDate</xsl:with-param>
                    <xsl:with-param name="displayName">Deletion Date</xsl:with-param>
                </xsl:call-template>
                <select name="Form_Product_Deleted" id="Form_Product_Deleted" onChange="checkDeleted(this.value)">
                    <xsl:if test="$openRuns = 1">
                        <xsl:attribute name="disabled" select="'disabled'" />
                    </xsl:if>
                    <option value="">
                      No
                    </option>
                    <option value="1">
                      <xsl:if test="Form/Product/Deleted = 1">
                        <xsl:attribute name="selected">selected</xsl:attribute>
                      </xsl:if>
                      Yes
                    </option>
                </select>

                <xsl:variable name="disableDeletionDate">
                    <xsl:if test="Form/Product/Deleted != 1 or not(normalize-space(Form/Product/Deleted))">1</xsl:if>
    	        </xsl:variable>

    		    <span id="deletionDate">
    				<label for="Form_Product_DeletedDate">Deletion Date:</label>
    	            <input type="text" class="dateField" name="Form_Product_DeletedDate" id="Form_Product_DeletedDate" value="{Form/Product/DeletedDate}">
    	              <xsl:if test="$disableDeletionDate = 1 or $openRuns = 1">
    	                <xsl:attribute name="disabled">disabled</xsl:attribute>
    	              </xsl:if>
    	            </input>

    	            <a title="Select Deletion Date">
    	                <img src="/production/images/icons/office/Calendar-(16x16).gif" height="16" width="16" class="calendarIcon" id="calendarIconDeletionDate">
    	                	<xsl:if test="$disableDeletionDate = 1 or $openRuns = 1">
    	                		<xsl:attribute name="class">hidden</xsl:attribute>
    	              		</xsl:if>
    	              	</img>
    	             </a>

					<xsl:call-template name="calendar">
						<xsl:with-param name="fieldID">Form_Product_DeletedDate</xsl:with-param>
						<xsl:with-param name="buttonID">calendarIconDeletionDate</xsl:with-param>
					</xsl:call-template>

                </span>

              </td>
            </tr>
        </xsl:if>

      </table>
    </div>
  </xsl:template>

  <xsl:template name="priceInfo">
    <fieldset>
      <legend>Prices</legend>
      <p class="formHeader">Enter price information here.</p>
      <hr />
      <div class="insideFieldset">
        <xsl:call-template name="column1PriceEdit" />
        <xsl:call-template name="column2PriceEdit" />
      </div>
    </fieldset>
  </xsl:template>

  <xsl:template name="column1PriceEdit">
    <div class="column1">
      <table>
        <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 1]">
          <xsl:call-template name="priceLevelRow" />
        </xsl:for-each>
        <tr>
          <td class="leftCol"><label for="Form_Product_DefaultPriceLevelID">Default:</label></td>
          <td>
            <xsl:call-template name="inlineError">
              <xsl:with-param name="path">Form/Product/DefaultPriceLevelID</xsl:with-param>
              <xsl:with-param name="displayName">Default</xsl:with-param>
            </xsl:call-template>
            <select name="Form_Product_DefaultPriceLevelID" class="type1" onChange="defaultPriceLevel(this.value)">
              <xsl:if test="$formatType != 1 or $formatType = '' or $openRuns = 1">
                <xsl:attribute name="disabled">disabled</xsl:attribute>
              </xsl:if>
              <option value="">Choose...</option>
              <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 1]">
                <option value="{PriceLevelID}">
                  <xsl:if test="PriceLevelID = /Root/Form/Product/DefaultPriceLevelID">
                    <xsl:attribute name="selected">selected</xsl:attribute>
                  </xsl:if>
                  <xsl:value-of select="Name" />
                </option>
              </xsl:for-each>
            </select>
            <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 1]">
              <xsl:if test="PriceLevelID = /Root/Form/Product/DefaultPriceLevelID">
                <script type="text/javascript">
                  requirePriceField(<xsl:value-of select="PriceLevelID" />,'Form_Product_PriceList_Price_<xsl:value-of select="PriceLevelID - 1" />_PriceID');
                </script>
              </xsl:if>
            </xsl:for-each>
          </td>
        </tr>
      </table>
    </div>
  </xsl:template>

  <xsl:template name="column2PriceEdit">
    <div class="column2">
      <table>
        <xsl:for-each select="Form/PriceLevelList/PriceLevel[Type = 2]">
          <xsl:call-template name="priceLevelRow" />
        </xsl:for-each>
      </table>
    </div>
  </xsl:template>

  <xsl:template name="priceLevelRow">
    <xsl:variable name="priceLevelID" select="PriceLevelID" />
    <tr>
      <td class="leftCol"><label for="Form_Product_PriceList_Price_{@i}_PriceID"><xsl:value-of select="Name" />:</label></td>
      <td>
        <xsl:call-template name="inlineError">
          <xsl:with-param name="path">Form/Product/PriceList/Price/<xsl:value-of select="@i" />/PriceID</xsl:with-param>
          <xsl:with-param name="displayName"><xsl:value-of select="Name" /></xsl:with-param>
        </xsl:call-template>
        <select name="Form_Product_PriceList_Price_{@i}_PriceID" class="type{Type}" id="Form_Product_PriceList_Price_{@i}_PriceID">
          <xsl:if test="$formatType != Type or $formatType = '' or $openRuns = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
          <option value="">Choose...</option>
          <xsl:for-each select="/Root/Form/PriceList/Price">
            <option value="{PriceID}">
              <xsl:if test="PriceID = /Root/Form/Product/PriceList/Price[PriceLevelID = $priceLevelID]/PriceID">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              <xsl:value-of select="Name" />
              (<xsl:call-template name="formatDollars">
                <xsl:with-param name="dollarAmount" select="Retail" />
              </xsl:call-template>)
            </option>
          </xsl:for-each>
        </select>
      </td>
    </tr>
  </xsl:template>


  <xsl:template name="servicesHash">
    <input type="hidden" name="serviceCount" id="serviceCount" value="{Form/ServiceList/Service/@size}" />
    <script type="text/javascript"> 
          //setting up service id/service name hash
          var serviceCollection = new Object();
          <xsl:for-each select="Form/ServiceList/Service">
            serviceCollection[<xsl:value-of select="ServiceID" />] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="ServiceName" /></xsl:call-template>';
          </xsl:for-each>
    </script>
  </xsl:template>


  <xsl:template name="trackList">
    <fieldset id="productTrackTable">
      <legend>Tracks</legend>
      <xsl:call-template name="trackErrorMessages" />
      <table class="textChart">
        <tbody>
          <tr>
            <th class="rowLeft" id="trackIncl">Status</th>
            <xsl:if test="$showAlbumPurchaseOnly = 1">
              <th id="trackAlbumOnly">
                Album Purchase Only
                <xsl:call-template name="helpIcon">
              	    <xsl:with-param name="tip">
              	        &lt;span style="font-weight: normal"&gt;
                      	    Some retailers do not accept album purchase only.
                      	    <xsl:value-of select="$tipBreak" />
                      	    <xsl:value-of select="$tipBreak" />
                      	    &lt;b&gt;If you don't want your album delivered to those retailers, you
                      	    <xsl:value-of select="$tipBreak" />
                      	    must deselect the &quot;approved for delivery&quot; checkbox in the
                      	    <xsl:value-of select="$tipBreak" />
                      	    album distribution settings page.&lt;/b&gt;
                      	    <xsl:value-of select="$tipBreak" />
                      	    <xsl:value-of select="$tipBreak" />
                      	    Retailers that accept album purchase only tracks are 24/7 Entertainment,
                      	    <xsl:value-of select="$tipBreak" />
                      	    Amazon, DJ Download, Juno, Liquid, MediaNet, MySpace Music, Napster,
                      	    <xsl:value-of select="$tipBreak" />
                      	    Nokia, Rhapsody, Shockhound/HotTopic, and Trackitdown.
                  	    &lt;/span&gt;
              	    </xsl:with-param>
                </xsl:call-template>
              </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&#160;#</th>
            <th id="discTrack">*Disc Track</th>
          </tr>
          <xsl:for-each select="/Root/Form/Product/TrackList/Track">
            <xsl:call-template name="trackListRow" />
          </xsl:for-each>
          <tr>
	          <td colspan="7">
	            <xsl:if test="$showAlbumPurchaseOnly = 1">
	                <xsl:attribute name="colspan">8</xsl:attribute>
	            </xsl:if>
	            <br />*Required field
	          </td>
	        </tr>
        </tbody>
      </table>
    </fieldset>
  </xsl:template>

  <xsl:template name="trackListRow">
    <xsl:variable name="trackPrefix">Form_Product_TrackList_Track_<xsl:value-of select="@i" />_</xsl:variable>
    <xsl:variable name="trackID" select="TrackID" />
    <input type="hidden" name="{$trackPrefix}TrackID" value="{$trackID}" />
    <tr class="row{position() mod 2}">
      <td>
      
        <select name="Included_Options_{@i}" id="Included_Options_{@i}" onChange="modifyProductTrack(this.value,{@i})">
            <xsl:if test="$openRuns = 1">
                <xsl:attribute name="disabled" select="'disabled'" />
            </xsl:if>
            
          <option value="Included">
            <xsl:if test="not(/Root/Params/ProductID) or Included = 1">
              <xsl:attribute name="selected">selected</xsl:attribute>
            </xsl:if>
            Included
          </option>

          <xsl:if test="($isPhysical = 0 or IsBonusTrack = 1) and /Root/Params/ProductID">         
            <option value="Bonus" id="Track_{@i}_IsBonusTrack">
              <xsl:if test="IsBonusTrack = 1">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              Bonus
            </option>
          </xsl:if>
          
          <option value="Not">
            <xsl:if test="/Root/Params/ProductID and (Included = 0 or Included = '')">
              <xsl:attribute name="selected">selected</xsl:attribute>
            </xsl:if>
            Not Included
          </option>
          
        </select>
        
        <input type="hidden" name="{$trackPrefix}Included" id="{$trackPrefix}Included">
         <xsl:attribute name="value">
           <xsl:choose>
              <xsl:when test="not(/Root/Params/ProductID) or Included = 1">1</xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
        </input>
        <input type="hidden" name="{$trackPrefix}IsBonusTrack" id="{$trackPrefix}IsBonusTrack">
         <xsl:attribute name="value">
           <xsl:choose>
              <xsl:when test="IsBonusTrack = 1">1</xsl:when>
              <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
        </input>
      </td>

      <xsl:if test="$showAlbumPurchaseOnly = 1">
        <td class="trackAlbumOnly">
          <select name="{$trackPrefix}AlbumOnly" id="{$trackPrefix}AlbumOnly" class="albumOnlyField">
              <xsl:if test="$openRuns = 1">
                <xsl:attribute name="disabled">disabled</xsl:attribute>
              </xsl:if>
            <option value="0">
              <xsl:if test="not(AlbumOnly)">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              No
            </option>
            <option value="1">
              <xsl:if test="AlbumOnly &gt; 0">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              Yes
            </option>
		  </select>
  	    </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:if test="DiscNumber/@e">
          <xsl:attribute name="class">discNumber errorInput</xsl:attribute>
        </xsl:if>
        <input type="text" class="discNumberField" name="{$trackPrefix}DiscNumber" id="{$trackPrefix}DiscNumber">
          <xsl:attribute name="value">
            <xsl:choose>
              <xsl:when test="normalize-space(DiscNumber)">
                <xsl:value-of select="DiscNumber" />
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="NextDiscNumber" />
              </xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
          <xsl:if test="/Root/Params/ProductID and Included != 1 and IsBonusTrack != 1 or $openRuns = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
      </td>
      <td>
        <xsl:if test="DiscTrack/@e">
          <xsl:attribute name="class">discTrack errorInput</xsl:attribute>
        </xsl:if>
        <input type="text" class="trackNumberField" name="{$trackPrefix}DiscTrack" id="{$trackPrefix}DiscTrack">
          <xsl:attribute name="value">
            <xsl:choose>
              <xsl:when test="normalize-space(DiscTrack)">
                <xsl:value-of select="DiscTrack" />
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="NextDiscTrack" />
              </xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
          <xsl:if test="/Root/Params/ProductID and Included != 1 and IsBonusTrack != 1 or $openRuns = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
      </td>
    </tr>
    <tr class="row{position() mod 2}" id="bonus{@i}">
      <xsl:if test="IsBonusTrack = 0 or IsBonusTrack = ''">
        <xsl:attribute name="style">display: none</xsl:attribute>
      </xsl:if>
      <td colspan="7">
        <xsl:if test="$showAlbumPurchaseOnly = 1">
            <xsl:attribute name="colspan">8</xsl:attribute>
        </xsl:if>
        <input type="button" name="launchBonus" id="launchBonus" value="Edit Services" onClick="editServices({@i},'{$calendarDateFormat}')">
            <xsl:if test="$openRuns = 1">
                <xsl:attribute name="disabled" select="'disabled'" />
            </xsl:if>
        </input>
        <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>
        <div id="bonusFields{@i}">
            <xsl:for-each select="BonusTrackList/BonusTrack">
                <input type="hidden" name="{$trackPrefix}BonusTrackList_BonusTrack_{ServiceID}_ServiceID" id="{$trackPrefix}BonusTrackList_BonusTrack_{ServiceID}_ServiceID" value="{ServiceID}" />
                <input type="hidden" name="{$trackPrefix}BonusTrackList_BonusTrack_{ServiceID}_DateStart" id="{$trackPrefix}BonusTrackList_BonusTrack_{ServiceID}_DateStart" value="{DateStart}" />
                <input type="hidden" name="{$trackPrefix}BonusTrackList_BonusTrack_{ServiceID}_DateEnd" id="{$trackPrefix}BonusTrackList_BonusTrack_{ServiceID}_DateEnd" value="{DateEnd}" />
            </xsl:for-each>
        </div>
      </td>
    </tr>
  </xsl:template>

  <xsl:template name="trackErrorMessages">
    <xsl:if test="Form/Product/TrackList/Track/*[@e or @emsg]">
      <div class="error" id="trackErrorTop">
        <xsl:if test="Form/Product/TrackList/Track/DiscNumber[@e = 'field_blank']">Disc Number cannot be blank.<br /></xsl:if>
        <xsl:if test="Form/Product/TrackList/Track/DiscTrack[@e = 'field_blank']">Disc Track cannot be blank.<br /></xsl:if>
        <xsl:if test="Form/Product/TrackList/Track/DiscNumber[@e = 'field_invalid']">Disc Number is invalid.<br /></xsl:if>
        <xsl:if test="Form/Product/TrackList/Track/DiscTrack[@e = 'field_invalid']">Disc Track is invalid.<br /></xsl:if>
        <xsl:if test="Form/Product/TrackList/Track/DiscNumber[@emsg]">Disc Number must be between 1 and 99.<br /></xsl:if>
        <xsl:if test="Form/Product/TrackList/Track/DiscTrack[@emsg]">Disc Track must be between 1 and 99.<br /></xsl:if>
      </div>
      <br />
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>
