<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:include href="/app/tools/support/templates/layout.xsl" />

  <xsl:template name="mainBody" >
    <xsl:call-template name="bodyTitle" >
      <xsl:with-param name="title">Mark Albums for Distribution</xsl:with-param>
    </xsl:call-template>
    <xsl:choose>
      <xsl:when test="IsSubmit &gt; 0 and not(Error)" >
        <xsl:call-template name="displaySubmitMessage" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="bodyMessage" />
        <xsl:call-template name="displayForm" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="displaySubmitMessage" >
    <xsl:variable name="url">/support/cm?c=ajax_mark_distribute<xsl:for-each select="Form/Deliver/ServiceID">&amp;deliver=<xsl:value-of select="." /></xsl:for-each><xsl:for-each select="Form/Redeliver/ServiceID">&amp;redeliver=<xsl:value-of select="." /></xsl:for-each></xsl:variable>

    <script type="text/javascript" >
      ajaxRequest( "<xsl:value-of select='$url' />", function() { alert( "Ajax Request Complete" ) } );
    </script>
    <h4>Ajax Command Called: </h4>
    <xsl:value-of select="$url" />

  </xsl:template>

  <xsl:template name="displayForm" >
    <form method="post" action="{$moduleURL}" >
      <input type="hidden" name="c"><xsl:attribute name="value"><xsl:value-of select="/Root/Cmd" /></xsl:attribute></input>
      <xsl:call-template name="displayServiceChecklist" />
      <xsl:call-template name="displayButtons" />
    </form>
  </xsl:template>

  <xsl:template name="displayServiceChecklist" >
    <fieldset>
      <legend>Services</legend>
      <table>

        <tr>
          <th></th>
          <th>Deliver</th>
          <th>Redeliver</th>
        </tr>

        <xsl:for-each select="Form/Services/Service" >
        <tr>
            <xsl:variable name="disabled"><xsl:choose><xsl:when test="Configured &gt; 0" >0</xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:variable>
            <xsl:call-template name="checkboxField" >
              <xsl:with-param name="label" ><xsl:value-of select="ServiceName" /></xsl:with-param>
              <xsl:with-param name="name" >Deliver_Service_<xsl:value-of select="ServiceID" /></xsl:with-param>
              <xsl:with-param name="disabled" ><xsl:value-of select="$disabled" /></xsl:with-param>
            </xsl:call-template>
            <xsl:call-template name="checkboxField" >
              <xsl:with-param name="name" >Redeliver_Service_<xsl:value-of select="ServiceID" /></xsl:with-param>
              <xsl:with-param name="disabled" ><xsl:value-of select="$disabled" /></xsl:with-param>
            </xsl:call-template>
        </tr>
        </xsl:for-each>
      </table>
    </fieldset>
  </xsl:template>

  <xsl:template name="displayButtons" >
    <xsl:call-template name="submitButton" >
      <xsl:with-param name="label">Mark Albums</xsl:with-param>
    </xsl:call-template>
  </xsl:template>

</xsl:stylesheet>
