/*******************************************************/
/*    renaud.guillaume@polytechnique.org               */
/*  script du site www.nousdesparisiens.ouvaton.org    */
/*******************************************************/

var photo = new Array(); //tableau de nom de photos
var legende = new Array(); //tableau des légendes
var i=0; //photo courante
var time=6000; //durée du diaporama

var diaporamaOn=0; //diaporama allumé ou éteint
var commentaire="Faîtes que le rêve dévore votre vie<br>Afin que la vie ne dévore pas votre rêve<br><br><a href='http://nousdesparisiens.ouvaton.org'>www.nousdesparisiens.ouvaton.org</a> <br><br>Derrière un site, il y a un humain.<br>Comme toi.<br><br><a href='mailto:renaud@ouvaton.org'> renaud@ouvaton.org</a>";
tempimg = new Image();

//variables de fonctionnement
var ii=0;
photo[0]="null";


function AffichePhoto(n)
//affiche la photo numéro n
  {

       document.getElementsByName("photo")[0].src=photo[n]; //"../photos/"+photo[n];
       document.getElementById('texte-legende').innerHTML="("+(n+1)+")&nbsp; &nbsp;"+legende[n];
  }

function Diaporama()
//diaporama de durée time en ms
  {
    retardphoto=setTimeout('Suivant()',1000);
    diaporama=setTimeout('Diaporama()',time);
  }

function Start()
//allume ou éteint le diaporama
   {
     if(diaporamaOn==0) 
     {
       diaporamaOn=1;
       //document.getElementsByName("diaporama")[0].src="../icones/pause.jpg";  //ici gérer l'affichage de pause
       //document.getElementsByName("diaporama")[0].onmouseover="document.diaporama.src='../icones/diaporama_dstd.jpg';";
       Diaporama();
     }
     else 
     {
       diaporamaOn=0;
       clearTimeout(diaporama);
       clearTimeout(retardphoto);
     }
   }


function Precedent()
//affiche la photo précédente
  {
    i--;
    if (i<0) {i = photo.length-1};
    AffichePhoto(i);
    /*on charge la photo precedente dans le cache client */
    if (i-1>=0) tempimg.src=photo[i-1];
    else tempimg.src=photo[photo.length-1];
  }


 function Suivant()
//affiche la photo suivante
  {
    i++;
    /*i%=photo.length;*/
    if (i>=photo.length) {i=0};
    AffichePhoto(i);
    /*on charge la photo suivante dans le cache client */
    if (i+1<photo.length) tempimg.src=photo[i+1];
    else tempimg.src=photo[0];
  }

function AfficheCommentaire()
//affiche la chaine commentaire dans l'ID #commentaire
   {
     document.write('<div id="commentaire">');
     document.write('<table width=100%><tr height=400px><td align="center">');
     document.write(commentaire);
     document.write('</td></tr></table>');
     document.write('</div>');
     AffichePhoto(0);}
   
function AfficheListe()
//crée et affiche la gallerie de photo
   {
    var chaine;
    var taille;
    document.write('<div id="gallerie"><ul>');
    document.write('<table width=100%><tr><td align="center">');
    for (ii=1;ii<photo.length;ii++)
    {
      chaine=photo[ii];
      taille=chaine.length;
      chaine=photo[ii].substring(0,taille-4);//extraction du '.jpg'
      chaine="../photos/"+chaine+"_petite.jpg";

      document.write('<li>');
      document.write('<img name="gallerie'+ii+'" alt="photo" src="' + chaine + '">');
      document.write('</li>');
    }
    document.write('</td></tr></table>');
    document.write('</ul></div>');
   }


