<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" indent="no" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
  <xsl:template match="mix">
    <html>
      <head>
        <link rel="stylesheet" type="text/css" href="../css/main.css"/>
        <link rel="stylesheet" type="text/css" href="../css/musica.css"/>
        <link rel="stylesheet" type="text/css" href="../css/mix.css"/>
        <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"/>
        <script language="javascript" type="text/javascript" src="../script/jquery.jtip-1.0.js"/>
        <script language="javascript" type="text/javascript">
          jQuery.noConflict();
          
          jQuery(document).ready(function($) {
            
            $("*[title],*[tooltip]").jtip({
              offsetX: 20,  // distanza dal centro del cursore
              offsetY: 10,  // distanza dal centro del cursore
              isFixed: true,  // fisso o mobile con il cursore
              showTimeout: 150,  // timeout prima di apparire
              hideTimeout: 10000,  // timeout prima di scomparire
              fadeIn: 100,  // fade in
              fadeOut: 500  // fade out
            });
            
          })
        </script>
      </head>
      <body>
        <xsl:call-template name="content"/>
      </body>
    </html>
  </xsl:template>
  <xsl:template name="content">
    <div id="left" class="mid">
      <xsl:call-template name="elenco">
        <xsl:with-param name="id" select="@xml"></xsl:with-param>
      </xsl:call-template>
      <div class="box rosso" style="text-align: left; width: 200px; float: left;">
        <h3>Copyright</h3>
        <ul>
          <li>Su questo sito sono presenti solo le playlist delle compilation</li>
          <li>Le copertine non possono essere scaricate</li>
          <li>Nessuno dei brani citati si trova su questo sito in forma digitale</li>
        </ul>
      </div>
    </div>
    <div id="content" class="extend mid right" style="float: right; width: 580px;">
      <div class="box blu" style="overflow: hidden;">
        <h1 class="Trebuchet">
          <u>
            <xsl:choose>
              <xsl:when test="logo">
                <img src="../images/compilation/{logo}" alt="{titolo}"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="titolo"/>
              </xsl:otherwise>
            </xsl:choose>
          </u>
        </h1>
        <xsl:if test="sottotitolo">
          <h2>
            <xsl:copy-of select="sottotitolo"/>
          </h2>
        </xsl:if>
        <xsl:if test="genere">
          <p class="genere">
            <xsl:value-of select="genere"/>
          </p>
        </xsl:if>
        <xsl:for-each select="brani">
          <xsl:if test="@sub">
            <a name="{position()}"/>
            <span class="cd">
              <xsl:value-of select="@sub"/>
            </span>
          </xsl:if>
          <table id="mix">
            <tbody>
              <xsl:choose>
                <xsl:when test="lato1 and count(lato1/brano) &gt;= count(lato2/brano)">
                  <!-- numero brani lato 1 >= numero brani lato 2 -->
                  <colgroup>
                    <col span="1" style="width: 50%;"/>
                    <col span="1" style="width: 50%;"/>
                  </colgroup>
                  <xsl:variable name="max" select="count(lato1/brano)"/>
                  <xsl:for-each select="lato1/brano">
                    <tr>
                      <td class="border" style="text-align: left;">
                        <xsl:if test="position() = last()">
                          <xsl:attribute name="style">border-bottom: none; text-align: left;</xsl:attribute>
                        </xsl:if>
                        <xsl:value-of select="position()"/>.
                        <xsl:apply-templates select="current()"/>
                      </td>
                      <xsl:variable name="pos" select="position()"/>
                      <td style="text-align: left;">
                        <xsl:if test="position() = last()">
                          <xsl:attribute name="style">border-bottom: none; text-align: left;</xsl:attribute>
                        </xsl:if>
                        <xsl:if test="../../lato2/brano[position()=$pos]">
                          <xsl:value-of select="position()+$max"/>.
                          <xsl:apply-templates select="../../lato2/brano[position()=$pos]"/>
                        </xsl:if>
                      </td>
                    </tr>
                  </xsl:for-each>
                </xsl:when>
                <xsl:when test="lato2 and count(lato1/brano) &lt; count(lato2/brano)">
                  <!-- numero brani lato 1 < numero brani lato 2 -->
                  <colgroup>
                    <col span="1" style="width: 50%;"/>
                    <col span="1" style="width: 50%;"/>
                  </colgroup>
                  <xsl:variable name="max" select="count(lato1/brano)"/>
                  <xsl:for-each select="lato2/brano">
                    <tr>
                      <xsl:variable name="pos" select="position()"/>
                      <td class="border" style="text-align: left;">
                        <xsl:if test="position() = last()">
                          <xsl:attribute name="style">border-bottom: none; text-align: left;</xsl:attribute>
                        </xsl:if>
                        <xsl:if test="../../lato1/brano[position()=$pos]">
                          <xsl:value-of select="position()"/>.
                          <xsl:apply-templates select="../../lato1/brano[position()=$pos]"/>
                        </xsl:if>
                      </td>
                      <td style="text-align: left;">
                        <xsl:if test="position() = last()">
                          <xsl:attribute name="style">border-bottom: none; text-align: left;</xsl:attribute>
                        </xsl:if>
                        <xsl:value-of select="position()+$max"/>.
                        <xsl:apply-templates select="current()"/>
                      </td>
                    </tr>
                  </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                  <!-- brani di un CD -->
                  <xsl:for-each select="brano">
                    <tr>
                      <td style="text-align: left;">
                        <xsl:if test="position() = last()">
                          <xsl:attribute name="style">border-bottom: none; text-align: left;</xsl:attribute>
                        </xsl:if>
                        <xsl:value-of select="position()"/>.
                        <xsl:apply-templates select="current()"/>
                      </td>
                    </tr>
                  </xsl:for-each>
                </xsl:otherwise>
              </xsl:choose>
            </tbody>
          </table>
        </xsl:for-each>
        <p style="text-align: center;">
          <xsl:for-each select="pics/pic">
            <!-- immagini di copertina -->
            <img src="../images/compilation/{text()}" alt="{@part}" title="{@part}" oncontextmenu="return false" galleryimg="no">
              <xsl:if test="@part != 'cd'">
                <xsl:attribute name="style">border: solid 1px #000; margin: 2px;</xsl:attribute>
              </xsl:if>
            </img>
            <br/>
          </xsl:for-each>
        </p>
        <p class="anno">COPYRIGHT © <xsl:value-of select="anno"/>. MADE IN ITALY BY DIEGO SYSTEM ® INC.
        ALL RIGHTS RESERVED. AUTHORISED COPYING, REPRODUCTION, HIRING, LENDING, PUBLIC
        PERFORMANCE AND BROADCASTING</p>
        <!-- copyright --></div>
    </div>
    <xsl:element name="script">
      <xsl:attribute name="language">javascript</xsl:attribute>
      <xsl:attribute name="type">text/javascript</xsl:attribute>
      // aggiorno il titolo della pagina
      parent.document.title += ' - <xsl:value-of select="titolo"/>';
    </xsl:element>
  </xsl:template>
  <xsl:template match="brano">
    <xsl:if test="@bonus">
      <!-- bonus track -->
      <span class="bonus">bonus track</span>&#160;</xsl:if>
    <xsl:choose>
      <xsl:when test="titolo">
        <xsl:call-template name="titolo"/>·
        <xsl:call-template name="autore"/>
      </xsl:when>
      <xsl:otherwise>
        <span class="titolo">
          <xsl:if test="text() = ''">unknown</xsl:if>
          <xsl:value-of select="text()"/>
        </span>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="titolo">
    <span class="titolo">
      <!-- titolo, se esiste -->
      <xsl:if test="titolo = ''">unknown</xsl:if>
      <xsl:value-of select="titolo"/>
    </span>
  </xsl:template>
  <xsl:template name="autore">
    <span class="autore">
      <!-- autore, se esiste -->
      <xsl:if test="autore = ''">unknown</xsl:if>
      <xsl:value-of select="autore"/>
    </span>
  </xsl:template>
  <xsl:include href="elenco.xsl"/>
</xsl:stylesheet>
