<!--
/* auteur: Bernard Martin-Rabaud */
/* Date de création: 13/06/2003 */
// CALQUES VERSION 1

// détermine le navigateur de l'utilisateur
var nn4 = (document.layers);
var dom = (document.getElementById);
var iex = (document.all);


// CLASSE CALQUE POUR DES CALQUES EXISTANTS
// le constructeur de la classe Calque admet 2 arguments :
// - l'id du layer
// - si le layer est visible ou pas (false/true) :
//   si cet argument est omis, le layer est rendu visible
function Calque(id) {
   this.id = id;
   this.x = null;
   this.y = null;
   this.layer = null;
   this.style = null;
   if (arguments.length == 2) this.visible = arguments[1];
   else this.visible = true;
   if (nn4) {
      if (document.layers[id]) {
         this.layer = document.layers[id];
         this.style = document.layers[id];
      }
   }
   else if (dom) {
      if (document.getElementById(id)) {
         this.layer = document.getElementById(id);
         this.style = document.getElementById(id).style;
      }
   }
   else if (iex) {
      if (document.all[id]) {
         this.layer = document.all[id];
         this.style = document.all[id].style;
      }
   }
   if (this.style) this.z = this.style.zIndex;
   else this.z = null;
}

// permet de masquer le calque
Calque.prototype.masquer = function() {
   if (this.style) {
      this.style.visibility = "hidden";
      this.visible = false;
   }
}

// permet de réafficher le calque
Calque.prototype.montrer = function() {
   if (this.style) {
      this.style.visibility = "visible";
      this.visible = true;
   }
}

// déplace le calque de dx horizontalement et de dy verticalement
Calque.prototype.deplacer = function(dx, dy) {
   if (this.style) {
      this.x = parseInt(this.style.left) + dx;
      this.y = parseInt(this.style.top) + dy;
      this.style.left = this.x;
      this.style.top = this.y;
   }
}

// déplace le calque vers le point (x, y)
Calque.prototype.deplacer_vers = function(x, y) {
   if (this.style) {
      this.x = x;
      this.y = y;
      this.style.left = x;
      this.style.top = y;
   }
}

// affecte le contenu en argument au calque
Calque.prototype.changer_contenu = function(valeur) {
   if (this.style) {
      if (nn4) {
         this.layer.document.write(valeur);
         this.layer.document.close();
      }
      else this.layer.innerHTML = valeur;
   }
}



// CLASSE DE GESTION DES CALQUES
function GestionCalques() {
   this.calques = new Array(); // tableau des calques
   this.calque_cour = -1;
}

// détermine quel indice de this.calques correspond à l'id
// si aucun calque n'a cette id, on en crée un nouveau
GestionCalques.prototype.cherche_id = function(id) {
   this.calque_cour = -1;
   for (var i=0;i<this.calques.length;i++) {
      if (this.calques[i].id == id) {
         this.calque_cour = i;
         break;
      }
   }
   if (this.calque_cour == -1) {
      this.calques[this.calques.length] = new Calque(id);
      this.calque_cour = this.calques.length - 1;
   }
}

// cache le calque d'id "id"
GestionCalques.prototype.masquer = function() {
   if (arguments.length == 1) this.cherche_id(arguments[0]);
   this.calques[this.calque_cour].masquer();
}

// réaffiche le calque d'id "id"
GestionCalques.prototype.montrer = function() {
   if (arguments.length == 1) this.cherche_id(arguments[0]);
   this.calques[this.calque_cour].montrer();
}

GestionCalques.prototype.deplacer_vers = function(x, y) {
   if (arguments.length == 3) this.cherche_id(arguments[2]);
   this.calques[this.calque_cour].deplacer_vers(x, y);
}

GestionCalques.prototype.deplacer = function(dx, dy) {
   if (arguments.length == 3) this.cherche_id(arguments[2]);
   this.calques[this.calque_cour].deplacer(dx, dy);
}

GestionCalques.prototype.changer_contenu = function(valeur) {
   if (arguments.length == 2) this.cherche_id(arguments[1]);
   this.calques[this.calque_cour].changer_contenu(valeur);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}