<?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" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <html>
      <head>
        <link rel="stylesheet" type="text/css" href="catalogue.css" />
        <title>Annuaire</title>
        <base target="_new" />
        <script>
          <xsl:comment>
            <![CDATA[
            var deplier = true;
            var replier = false;
            function deplirepli(titre, depli) {
              plus = titre.children[0];
              moins = titre.children[1];
              div = titre.parentElement;
              moins.style.display = depli ? "" : "none";
              plus.style.display = depli ? "none" : "";
              titre.title="Cliquer pour " + (depli ? "re" : "dé" ) + "plier";
              div.children[1].style.display= depli ? "" : "none";
            }
            function deplirepliTout(action) {
              coll = document.all.tags("div" );
              for (i=0; i<coll.length; i++) {
                if (coll[i].className == "title" ) {
                  deplirepli(coll[i], action);
                }
              }
            }
            function toggleDisplay(titre) {
              plus = titre.children[0];
              if (plus.style.display=="" )
            }
            ]]>
          </xsl:comment>
        </script>
      </head>
      <BODY>
        <DIV id="listing">
          <xsl:apply-templates select="catalogue" />
        </DIV>
        <P class="petit">
          <A HREF="mailto:aaa@toto.fr">Signaler toute anomalie</A>
        </P>
      </BODY>
    </html>
  </xsl:template>
  <xsl:template match="catalogue">
    <h1 id="titre">
      <input class="grosbouton" style="float:left" type="button" value="++" title="Tout déplier" onclick="deplirepliTout(deplier)" />
      <input class="grosbouton" style="float:right" type="button" value="--" title="Tout replier" onclick="deplirepliTout(replier)" />Annuaire
      <span style="cursor:hand" title="Annuaire">HHHHH</span>
    </h1>
    <xsl:apply-templates select="categorie"/>
  </xsl:template>
  <xsl:template match="categorie">
      <DIV CLASS="wrapping">
        <DIV CLASS="title" onclick="toggleDisplay(this)">
          <xsl:attribute name="title">
            <xsl:if test="aide">
              <xsl:value-of select="aide" />
            </xsl:if>Cliquez vite pour en savoir plus</xsl:attribute>
          <SPAN>+</SPAN>
          <SPAN STYLE="display:none">-</SPAN>
          <xsl:value-of select="nom" />
        </DIV>
        <DIV CLASS="wrapping" STYLE="display:none">
          <xsl:apply-templates select="categorie"/>
          <xsl:if test="document">
            <table class="persons">
              <xsl:apply-templates select="document" />
            </table>
          </xsl:if>
        </DIV>
      </DIV>
  </xsl:template>
  <xsl:template match="document">
      <tr class="document">
        <xsl:attribute name="ID">
          <xsl:value-of select="generate-id()"/>
        </xsl:attribute>
        <td>
          <a>
            <xsl:attribute name="name">
              <xsl:value-of select="generate-id()"/>
            </xsl:attribute>
          </a>
          <a>
            <xsl:attribute name="title">Cliquer pour envoyer un message</xsl:attribute>
            <xsl:attribute name="href">
              <xsl:value-of select="ref" />
            </xsl:attribute>
            <xsl:value-of select="titre" />
          </a>
        </td>
        <td>
          <xsl:value-of select="poste" />
        </td>
        <td>
          <xsl:value-of select="secteur" />
        </td>
        <td>
          <xsl:value-of select="tel" />
        </td>
        <td>
          <xsl:value-of select="grade" />
        </td>
      </tr>
  </xsl:template>
</xsl:stylesheet>