function slide() {
  this.Im=new Array();
  this.nb=null;  // tableau qui associe à un nom d'image son rang
  this.names=null; // noms des images
  this.path=null;  // 
  this.current=0;
  this.imge=null;  // répertoire d'images, chemin relatif
  this.comment= null;
  this.idcomment=null;

// initialisation pour une application particulière (page web)
// s contient les noms des images séparées par des espaces
// tcom est un tableau contenant les commentaires associés aux images
// idcom est l'identificateur id du div qui accueillira le commentaire
  function init(s, path, iname, tcom, idcom) {
    this.comment = tcom;
    this.idcomment = idcom;
    this.imge=iname;
    this.path=path;
    this.names= s.split(/\s+/g);
    this.nb = new Array();
    for(var i=0;i<this.names.length;i++) {
     this.nb[this.names[i]]=i;
    }
//alert(this.names.length)
  }
  this.init=init;

  function preload(k) {
//alert("preload "+k)
    if (this.Im[k]==null) {
     this.Im[k]=new Image();
     this.Im[k].src=this.path+"/"+this.names[k];
    }
  }
  this.preload=preload;

  function suivant(x) {
    this.current += x+this.names.length;
    this.current = this.current%this.names.length;
    this.setcommt(this.current);
    this.setimg(this.current);
  }
  this.suivant=suivant;

  function setimg(k) {
    this.preload(k);
    this.current = k;
    document.images[this.imge].src=this.Im[k].src;
    //this.setcommt(k);
    //alert(k+" "+this.comment[k]+" "+this.Im[k].src);
    this.preload(k+1);
  }
  this.setimg=setimg;

  function setcommt(k) {
    if(this.comment!=null && this.comment[k]!=null) {
      document.getElementById(this.idcomment).innerHTML=this.comment[k];
    }
  }
  this.setcommt = setcommt;

  function set(sn) {
    this.setimg(this.nb[sn]);
    this.setcommt(this.nb[sn]);
  }
  this.set=set;

  function extrem(x) {
    var k;
    if(x==0) k = 0;
    else k= this.names.length-1;
    this.setimg(k);
    this.setcommt(k);
  }
  this.extrem=extrem;

  function loadexple(s) {
    this.setimg[nb[s]]; 
    document.location.href="#SL";
  }
  this.loadexple=loadexple;
}


