var TAB_DIAPORAMA = new Array();
function GetDiaporamaByID(id) {
    return TAB_DIAPORAMA[id];
}

function Diaporama() {
    this.id = TAB_DIAPORAMA.length;
    TAB_DIAPORAMA[this.id] = this;
      if (document.all)
        {
            var output = "<div id='diap_tooltip_"+this.id+"' style='position:absolute;padding:2px;";
            output += "background-color:lightyellow;width:150;height:40;border:1px lightgrey solid;z-index:10;visibility:hidden'";
            output += "></div>";
            document.write(output);
        }
}

function Diaporama_GroupeImg(title) {
    this.title = title;
    this.t_imgs = new Array();
    this.length = 0;
}
Diaporama_GroupeImg.prototype.AddImage = Diaporama_GroupeImg_AddImage;
Diaporama_GroupeImg.prototype.Get = Diaporama_GroupeImg_Get;

function Diaporama_GroupeImg_Get(i) {
    return this.t_imgs[i];
}

function Diaporama_GroupeImg_AddImage (src,width,height,title,lien,alt,newWindow,params) {
    obj_img = new Object();
    var img = new Image();
    img.src = src;
    obj_img.src = src;
    obj_img.width = width;
    obj_img.height = height;
    obj_img.title = title;
    obj_img.lien = lien;
    obj_img.alt = alt;
    obj_img.newWindow = newWindow;
    obj_img.params = params;	
    this.length++;
    this.t_imgs[this.t_imgs.length] = obj_img;
}

Diaporama.prototype.Init = Diaporama_Init;
Diaporama.prototype.AddImage = Diaporama_AddImage;
Diaporama.prototype.AddGroupe = Diaporama_AddGroupe;
Diaporama.prototype.RenderBlocImg = Diaporama_RenderBlocImg;
Diaporama.prototype.RenderBlocText = Diaporama_RenderBlocText;
Diaporama.prototype.ComputeDimension = Diaporama_ComputeDimension;
Diaporama.prototype.Play = Diaporama_Play;
Diaporama.prototype.Stop = Diaporama_Stop;
Diaporama.prototype.Run = Diaporama_Run;
Diaporama.prototype.Next = Diaporama_Next;
Diaporama.prototype.Previous = Diaporama_Previous;
Diaporama.prototype.FormatLegend = Diaporama_FormatLegend;
Diaporama.prototype.__RefreshSlide = Diaporama_RefreshSlide;
Diaporama.prototype.__RefreshLegend = Diaporama_RefreshLegend;
Diaporama.prototype.__OpenImgInfo = Diaporama_OpenImgInfo;
Diaporama.prototype.__CloseImgInfo = Diaporama_CloseImgInfo;
Diaporama.prototype.__BuildLayer = Diaporama_BuildLayer;
Diaporama.prototype.__WriteBlocImg = Diaporama_WriteBlocImg;
Diaporama.prototype.__WriteBlocText = Diaporama_WriteBlocText;

function Diaporama_Init(containerID,type,b_auto,b_pos,b_legende,pause,width,height) {
    // si width = 0 (height = 0) alors la largeur du diaporama est fixé par son contenu
    this.containerID = containerID;
    this.type = type;
    this.b_auto = b_auto;
    this.b_pos = b_pos;
    this.b_legende = b_legende;
    this.pause = pause;
    this.width = width;
    this.height = height;
    this.slide_width = 0;
    this.slide_height = 0;
    this.timer = null;
    this.nbphoto = 0;
    this.nbslide = 0;
    this.preview_state = 0;
    this.firstslide = 1;
    this.b_scroller_up = true;
    this.b_scrolling = false;
    this.scroller_firstlayer = 0;
    this.scroller_step = 5;
    this.speed = 2;
    this.t_slide = new Array();
    this.t_grp = new Array();
    this.t_grp[0] = new Diaporama_GroupeImg();
    this.t_grp[0].AddRefGroupe = function(i) { this.t_imgs[this.length] = i; this.length++; }
}

function Diaporama_ComputeDimension() {
    for(var i=0 ; i < this.t_grp[0].length ; i++)
        {
            var slide = this.t_grp[0].Get(i);
            if (this.slide_width < (slide.width)) this.slide_width = slide.width;
            if (this.slide_height < (slide.height)) this.slide_height = slide.height;
        }
    if (this.width == 0)
        this.width =  (this.slide_width < 100) ? 100 : this.slide_width;
    else
        this.slide_width = this.width;
    if (this.height == 0)
        this.height = (this.slide_height < 100) ? 100 : this.slide_height;
    else
        this.slide_height = this.height;
}

function Diaporama_AddImage(igrp,src,width,height,title,lien,alt,newWindow,params) {
    this.nbphoto++;
    this.t_grp[igrp].AddImage(src,width,height,title,lien,alt,newWindow,params);
}

function Diaporama_AddGroupe(title) {
    var grp = new Diaporama_GroupeImg(title);
    this.t_grp[this.t_grp.length] = grp;
    this.t_grp[0].AddRefGroupe(this.t_grp.length-1);
    return this.t_grp.length-1;
}


function Diaporama_BuildLayer(src,lien,alt,newWindow,params,w,h,num) {
    var slayer = "";
    var rapporthauteur = 0;
    var rapportlargeur = 0;
    largeur = w;
    hauteur = h;
    if (this.height!=0)
       rapporthauteur=hauteur/this.height;
    else
       rapporthauteur=0;
    if (this.width!=0)
       rapportlargeur=largeur/this.width;
    else
       rapportlargeur=0;
    if (rapportlargeur>1 || rapporthauteur>1)
    {
      if (rapportlargeur>=rapporthauteur)
      {
        largeur = (this.width-2);
        if (rapporthauteur!=0)
          hauteur = Math.min(Math.floor(hauteur/rapportlargeur),(this.height-2));
      }
      else
      {
        hauteur = (this.height-2);
        if (rapportlargeur!=0)
          largeur = Math.min(Math.floor(largeur/rapporthauteur),(this.width-2));
      }
    }
    if (document.all)
        {
            slayer = "<div border='1' style='position:relative;width:"+largeur+"px;height:"+hauteur+"px;overflow:hidden' ";
            slayer += "onmouseover='GetDiaporamaByID("+this.id+").__OpenImgInfo("+num+",event);' ";
            slayer += "onmouseout='GetDiaporamaByID("+this.id+").__CloseImgInfo();' >";
            if (lien!="")
            {
              slayer += "<a href='"+lien+"' ";
              if (newWindow)
                  slayer +="target='_blank' ";
              else
                  slayer +="target='_self' ";
	      if (params) {
		  slayer += "onclick=\""+params+"\" "	
	      }		
              slayer += "><img src='"+src+"' border='0' width='"+largeur+"' height='"+hauteur+"' alt='"+alt+"'></a>";
            }
            else
              slayer += "<img src='"+src+"' border='0' width='"+largeur+"' height='"+hauteur+"'>";
            slayer += "</div>";
        }
    else if (document.layers)
        {
            if (lien!="")
            {
              slayer += "<a href='"+lien+"' ";
              if (newWindow)
                  slayer +="target='_blank'>";
              else
                  slayer +="target='_self' ";
	      if (params) {
		  slayer += "onclick=\""+params+"\" "	
	      }		
              slayer += "><img src='"+src+"' border='0' width='"+largeur+"' height='"+hauteur+"' alt='"+alt+"'></a>";
            }
            else
              slayer += "<img src='"+src+"' border='0' width='"+largeur+"' height='"+hauteur+"'>";
        }
    return slayer;
}

function Diaporama_RenderBlocImg() {
    this.ComputeDimension();
    // Compilation des diapos => remplissage du tableau this.t_slide
    var num_img = 0;
    this.nbslide = this.t_grp[0].length;
    for(var i=0 ; i < this.nbslide ; i++)
        {
            var slide = this.t_grp[0].Get(i);
            var output = "<table cellspacing='0' cellpadding='0' border='0' ";
            output += "width='"+this.slide_width+"' height='"+this.slide_height+"'>";
            if (typeof(slide) == "number")
                {
                    var grp = this.t_grp[slide];
                    if (this.type != 24) output += "<tr>";
                    for(var j=0 ; j < grp.length ; j++)
                        {
                            num_img++;
                            var obj_img = grp.Get(j);
                            if (this.type == 24)
                                {
                                    output += "<tr><td valign='middle' align='center'>";
                                    output += this.__BuildLayer(obj_img.src,obj_img.lien,obj_img.alt,obj_img.newWindow,obj_img.params,obj_img.width, obj_img.height, num_img);
                                    output += "</td></tr>";
                                }
                            else
                                {
                                    output += "<td valign='middle' align='center'>";
                                    output += this.__BuildLayer(obj_img.src,obj_img.lien,obj_img.alt,obj_img.newWindow,obj_img.params, obj_img.width, obj_img.height, num_img);
                                    output += "</td>";
                                }
                        }
                    if (this.type != 24) output += "</tr>";
                }
            else
                {
                    num_img++;
                    output += "<tr><td valign='middle' align='center'>";
                    output += this.__BuildLayer(slide.src,slide.lien,slide.alt,slide.newWindow,slide.params,slide.width,slide.height,num_img);
                    output += "</td></tr>";
                }
            output += "</table>";
            this.t_slide[i] = output;
        }
    var output = "";
    if (document.all)
        {
            output = "<div id='diaporama_"+this.id+"' style='position:relative;width:"+this.width;
            output += "px;height:"+this.height+"px;overflow:hidden;'>";
        }
    else
        {
            output = "<ilayer id='diaporama_"+this.id+"' width='"+this.width+"' height='"+this.height;
            output += "' CLIP='"+this.width+","+this.height+"'>";
        }


    if (this.type == 23 || this.type == 24)
        {
            var firstSlide = this.nbslide-1;
            var lastSlide = this.nbslide == 1 ? 0 : 1;
            if (document.layers)
                {
                    for(var i = -1 ; i < 2 ; i++)
                        {
                            output += "<layer width="+this.slide_width+" height="+this.slide_height;
                            output += " clip="+this.slide_width+","+this.slide_height;
                            if (this.type == 23)
                                output += " top=0 left="+(this.slide_width*i);
                            else
                                output += " left=0 top="+(this.slide_height*i);
                            output += ">";
                            output += this.t_slide[i == -1 ? firstSlide : (i == 0 ? 0 :lastSlide)];
                            output += "</layer>";
                        }
                }
            else if (document.all)
                {
                    for(var i = -1 ; i < 2 ; i++)
                        {
                            output += "<div style='position:absolute;width:"+this.slide_width+"px;height:"+this.slide_height;
                            output += "px;overflow:hidden;";
                            if (this.type == 23)
                                output += "top:0px;left:"+(this.slide_width*i)+"px;'";
                            else
                                output += "left:0px;top:"+(this.slide_height*i)+"px;'";
                            output += ">";
                            output += this.t_slide[i == -1 ? firstSlide : (i == 0 ? 0 :lastSlide)];
                            output += "</div>";
                        }
                }
        }
    else
        {
            if (document.layers)
                {
                    output += "<layer width="+this.slide_width+" height="+this.slide_height;
                    output += " clip="+this.slide_width+","+this.slide_height + ">";
                    output += this.t_slide[0];
                    output += "</layer>";
                }
            else if (document.all)
                {
                    output += this.t_slide[0];
                }
        }

    output += document.all ? "</div>" : "</ilayer>";
    this.output = output;

    this.__WriteBlocImg();
}

function Diaporama_WriteBlocImg() {
    if (!isDiffusion)
        {
            while(!document.all("diap1_"+this.containerID))
                {
                    if (this.timer) clearTimeout(this.timer);
                    this.timer = setTimeout("GetDiaporamaByID("+this.id+").__WriteBlocImg();", 100);
                    return;
                }
            document.all("diap1_"+this.containerID).innerHTML = this.output;
            this.preview_state |= 1;
            if (this.preview_state == 3 && this.b_auto)
                {
                    this.Play();
                }
            return;
        }
    document.write(this.output);
}

function Diaporama_FormatLegend(i) {
    var slide = this.t_grp[0].Get(i-1);
    var b_grp = false;
    var output = "";
    if (typeof(slide) == "number")
        {
            b_grp = true;
            slide = this.t_grp[slide];
        }
    if (this.b_legende)
    {
      output = "<P align=center class='legend' accessoryGroups='hsh_legend'><B>";
      output += slide.title + "</B><BR>";
    }
    else
    {
      output = "<P align=center class='text' accessoryGroups='hsh_text'>";
    }
    if (this.b_pos)
        {
            output += "<B>"+Photo;
            if (b_grp && slide.length > 1) output += "s";
            output += " ";
            var n = 1;
            for(var j=0 ; j < i-1 ; j++)
                {
                    var prec = this.t_grp[0].Get(j);
                    n += (typeof(prec) == "number") ? this.t_grp[prec].length : 1;
                }
            output += n;
            if (b_grp)
                {
                    output += " - ";
                    output += n + slide.length - 1;
                }
            output += " : " + this.nbphoto;
            output += "</B>";
        }
    output += "<BR>&nbsp;</P>";
    return output;
}

function Diaporama_RenderBlocText() {
    var output = "";
    if (this.wlegend == 0) this.wlegend = this.width;

    if (document.all)
        {
            output = "<center><div id='diaporama_legend_"+this.id+"' class='legendediaporama' style='";
            output += "position:relative;width:"+this.width+";height:0;";
            output += "'>";
            output += this.FormatLegend(1);
            output += "</div></center>";
        }
    else if (document.layers)
        {
            output = "<center><ilayer top=0 left=0 class='legendediaporama' id='diaporama_legend_"+this.id+"' ";
            output += "width="+this.width+" height=0>";
            output += "<layer top=0 left=0 width="+this.width+" height=0>";
            output += this.FormatLegend(1);
            output += "</layer></ilayer></center>";
        }
    this.output_legend = output;
    this.__WriteBlocText();
}

function Diaporama_WriteBlocText() {
    if (!isDiffusion)
        {
            while(!document.all("diap2_"+this.containerID))
                {
                    if (this.timer) clearTimeout(this.timer);
                    this.timer = setTimeout("GetDiaporamaByID("+this.id+").__WriteBlocText();", 100);
                    return;
                 }
            document.all("diap2_"+this.containerID).innerHTML = this.output_legend;
            this.preview_state |= 2;
            if (this.preview_state == 3 && this.b_auto)
                {
                    this.Play();
                }
            return;
        }
    document.write(this.output_legend);
    if (this.b_auto)
        {
            addLoadAction(new Function("GetDiaporamaByID("+this.id+").Play()"));
        }
}

function Diaporama_Play() {
    this.Stop();
    if (this.type == 23 || this.type == 24)
        this.timer = setTimeout("GetDiaporamaByID("+this.id+").Run()", this.pause);
    else
        this.Run();
}

function Diaporama_Stop() {
    if (this.timer)
        {
            clearTimeout(this.timer);
            this.timer = null;
        }
}

function Diaporama_Run() {
    if (!isDiffusion && !document.all["diaporama_"+this.id])
        {
          this.Stop();
          return;
        }
    if (this.type == 24 || this.type == 23)
        {
            var layers = null;
            var bScroll = false;
            var posX = 0;
            var posY = 0;
            if (document.layers)
                {
                    layers = document.layers["diaporama_"+this.id].document.layers;
                    posX = layers[this.scroller_firstlayer].left;
                    posY = layers[this.scroller_firstlayer].top;
                }
            else if (document.all)
                {
                    layers = document.all["diaporama_"+this.id].children;
                    posX = layers[this.scroller_firstlayer].style.pixelLeft;
                    posY = layers[this.scroller_firstlayer].style.pixelTop;
                }
            else
                return;
            if (this.type == 23)
                {
                    if (this.b_scroller_up)
                        bScroll = posX > -(this.slide_width << 1);
                    else
                        bScroll = posX < 0;
                }
            else
                {
                    if (this.b_scroller_up)
                        bScroll = posY > -(this.slide_height << 1);
                    else
                        bScroll = posY < 0;
                }
            this.b_scrolling = bScroll;
            if (bScroll)
                {
                    var shift = 0;
                    if (this.type == 23)
                        {
                            if (this.b_scroller_up)
                                {
                                    shift = -this.scroller_step;
                                    if ((this.slide_width<<1) + posX < this.scroller_step)
                                        shift = -((this.slide_width<<1) + posX);
                                }
                            else
                                {
                                    shift = this.scroller_step;
                                    if (-posX < this.scroller_step)
                                        shift = -posX;
                                }
                            for(var i=0 ; i < 3 ; i++)
                                {
                                    var layer = layers[(this.scroller_firstlayer + i) % 3];
                                    if (document.layers)
                                        layer.left += shift;
                                    else
                                        layer.style.pixelLeft += shift;
                                }
                        }
                    else
                        {
                            if (this.b_scroller_up)
                                {
                                    shift = -this.scroller_step;
                                    if ((this.slide_height<<1) + posY < this.scroller_step)
                                        shift = -((this.slide_height<<1) + posY);
                                }
                            else
                                {
                                    shift = this.scroller_step;
                                    if (-posY < this.scroller_step)
                                        shift = -posY;
                                }
                            for(var i=0 ; i < 3 ; i++)
                                {
                                    var layer = layers[(this.scroller_firstlayer + i) % 3];
                                    if (document.layers)
                                        layer.top += shift;
                                    else
                                        layer.style.pixelTop += shift;
                                }
                        }
                    this.timer = setTimeout("GetDiaporamaByID("+this.id+").Run()" , this.speed);
                }
            else
                {
                  if (this.b_scroller_up)
                   {
                    var output = this.t_slide[(this.firstslide+1) % this.nbslide];
                    var layer = layers[this.scroller_firstlayer];
                    if (this.type == 23)
                        {
                            if (document.layers)
                                layer.left = this.slide_width;
                            else
                                layer.style.pixelLeft = this.slide_width;
                        }
                    else
                        {
                            if (document.layers)
                                layer.top = this.slide_height;
                            else
                                layer.style.pixelTop = this.slide_height;
                        }
                    if (document.layers)
                        {
                            layers[this.scroller_firstlayer].document.write(output);
                            layers[this.scroller_firstlayer].document.close();
                        }
                    else
                        {
                            layers[this.scroller_firstlayer].innerHTML = output;
                        }
                    this.firstslide = this.firstslide == this.nbslide ? 1 : this.firstslide+1;
                    this.scroller_firstlayer = (this.scroller_firstlayer + 1) % 3;
                   }
                  else
                   {
                    var output = this.t_slide[Modulo(this.firstslide - 3 , this.nbslide)];
                    var layer = layers[(this.scroller_firstlayer+2) % 3];
                    if (this.type == 23)
                        {
                            if (document.layers)
                                layer.left = -this.slide_width;
                            else
                                layer.style.pixelLeft = -this.slide_width;
                        }
                    else
                        {
                            if (document.layers)
                                layer.top = -this.slide_height;
                            else
                                layer.style.pixelTop = -this.slide_height;
                        }
                    if (document.layers)
                        {
                            layer.document.write(output);
                            layer.document.close();
                        }
                    else
                        {
                            layer.innerHTML = output;
                        }
                    this.firstslide = Modulo(this.firstslide - 2 , this.nbslide) + 1;
                    this.scroller_firstlayer = this.scroller_firstlayer == 0 ? layers.length-1 : this.scroller_firstlayer-1;
                   }
                    this.__RefreshLegend();
                    if (this.b_auto)
                        {
                            this.Stop();
                            this.timer = setTimeout("GetDiaporamaByID("+this.id+").Next()", this.pause);
                        }
                }
        }
    else
        {
            this.Stop();
            if (document.all && ((this.type >=1 && this.type<=22)||this.type>=25))
                {
                    var layer = document.all("diaporama_"+this.id);
                        if (layer && layer.filters.length != 0)
                        {
                              if (layer.filters[0].status == 2)
                                   this.timer = setTimeout("GetDiaporamaByID("+this.id+").Run()", 50);
                      }
                }
            if (this.b_auto)
               this.timer = setTimeout("var diap=GetDiaporamaByID("+this.id+");diap.Next();diap.Run()", this.pause);
        }
}

function Modulo(q,r) {
    while (q < 0)
        q += r;
    return q % r;
}

function Diaporama_Next() {
    if (document.all && ((this.type >=1 && this.type<=22)||this.type>=25))
        {
            var layer = document.all("diaporama_"+this.id);
            if (layer && layer.filters.length != 0)
                {
                    if (layer.filters[0].status == 2) {
                        var type = this.type;
                        this.type = 0;
                        this.__RefreshSlide();
                        this.type = type;
                        return;
                    }
                }
        }
     if (this.type == 23 || this.type == 24)
        {
            if (!this.b_scrolling)
                {
                this.Stop();
                  this.b_scroller_up = true;
                  this.Run();
                }
        }
     else
        {
            this.Stop();
          this.firstslide = (this.firstslide >= this.nbslide) ? 1 : this.firstslide + 1;
            this.__RefreshSlide();
        }
}

function Diaporama_Previous() {
    if (document.all &&((this.type >=1 && this.type<=22)||this.type>=25))
        {
            var layer = document.all("diaporama_"+this.id);
            if (layer && layer.filters.length != 0)
                {
                    if (layer.filters[0].status == 2) {
                        var type = this.type;
                        this.type = 0;
                        this.__RefreshSlide();
                        this.type = type;
                        return;
                    }
                }
        }
     if (this.type == 23 || this.type == 24)
        {
            if (!this.b_scrolling)
                {
                    this.Stop();
                    this.b_scroller_up = false;
                    this.Run();
                }
        }
     else
        {
            this.Stop();
          this.firstslide = (this.firstslide == 1) ? this.nbslide : this.firstslide - 1;
            this.__RefreshSlide();
        }
}

effets = new Array();
effets[1] = "DXImageTransform.Microsoft.Iris(irisstyle='SQUARE', motion='in',";
effets[2] = "DXImageTransform.Microsoft.Iris(irisstyle='SQUARE', motion='out',";
effets[3] = "DXImageTransform.Microsoft.Iris(irisstyle='CIRCLE', motion='in',";
effets[4] = "DXImageTransform.Microsoft.Iris(irisstyle='CIRCLE', motion='out',";
effets[5] = "DXImageTransform.Microsoft.Blinds(direction='up', bands=1,";
effets[6] = "DXImageTransform.Microsoft.Blinds(direction='down', bands=1,";
effets[7] = "DXImageTransform.Microsoft.Blinds(direction='right', bands=1,";
effets[8] = "DXImageTransform.Microsoft.Blinds(direction='left', bands=1,";
effets[9] = "DXImageTransform.Microsoft.Blinds(direction='right',";
effets[10] = "DXImageTransform.Microsoft.Blinds(direction='down',";
effets[11] = "DXImageTransform.Microsoft.CheckerBoard(direction='right',";
effets[12] = "DXImageTransform.Microsoft.CheckerBoard(direction='down',";
effets[13] = "DXImageTransform.Microsoft.Barn(orientation='vertical', motion='in',";
effets[14] = "DXImageTransform.Microsoft.Barn(orientation='vertical', motion='out',";
effets[15] = "DXImageTransform.Microsoft.Barn(orientation='horizontal', motion='in',";
effets[16] = "DXImageTransform.Microsoft.Barn(orientation='horizontal', motion='out',";
effets[17] = "DXImageTransform.Microsoft.Strips(motion='leftdown',";
effets[18] = "DXImageTransform.Microsoft.Strips(motion='leftup',";
effets[19] = "DXImageTransform.Microsoft.Strips(motion='rightdown',";
effets[20] = "DXImageTransform.Microsoft.Strips(motion='rightup',";
effets[21] = "DXImageTransform.Microsoft.RandomBars(orientation='horizontal',";
effets[22] = "DXImageTransform.Microsoft.RandomBars(orientation='vertical',";
effets[26] = "DXImageTransform.Microsoft.RandomDissolve(";

function Diaporama_RefreshSlide() {
    if (this.type != 23 && this.type != 24)
        {
            if (document.all)
                {
                    var layer = document.all("diaporama_"+this.id);
                    if (!layer) return;
                    for(var i=0 ; i < layer.filters.length ; i++)
                        layer.filters[i].stop();
                    var sfilter = "";
                    if ((this.type >=1 && this.type<=22)||this.type>=25)
                        {
                            if (this.type == 26)
                                sfilter = "progid:DXImageTransform.Microsoft.Fade(Overlap=0.25,duration=";
                            else
                                sfilter = "progid:" + effets[this.type] + "duration=";
                            sfilter += this.speed + ")";
                            layer.style.filter = sfilter;
                        }
                    if (((this.type >=1 && this.type<=22)||this.type>=25) && layer.filters.length == 1)
                        {
                            var filter = layer.filters[0];
                            filter.apply();
                            layer.innerHTML = this.t_slide[this.firstslide-1];
                            filter.play();
                        }
                    else
                        {
                            layer.innerHTML = this.t_slide[this.firstslide-1];
                        }
                }
            else if (document.layers)
                {
                    var layer = document.layers["diaporama_"+this.id].document.layers[0];
                    layer.document.write(this.t_slide[this.firstslide-1]);
                    layer.document.close();
                }
        }
        this.__RefreshLegend();
}

function Diaporama_RefreshLegend() {
    if (document.all)
        {
            var layer = document.all("diaporama_legend_"+this.id);
            if (!layer) return;
            layer.innerHTML = this.FormatLegend(this.firstslide);
        }
    else if (document.layers)
        {
            var layer = document.layers["diaporama_legend_"+this.id].document.layers[0];
            layer.document.write(this.FormatLegend(this.firstslide));
            layer.document.close();
        }
}


function Diaporama_OpenImgInfo(num, event) {
    var img = null, k = 0, bgrp = false;
    for(var i = 0 ; i < this.nbslide ; i++)
        {
            var slide = this.t_grp[0].Get(i);
            if (typeof(slide) == "number")
                {
                    var grp = this.t_grp[slide];
                    if (k+grp.length >= num)
                        {
                            bgrp = true;
                            img = grp.Get(num - k -1);
                            break;
                        }
                    else
                        {
                            k += grp.length;
                        }
                }
            else
                {
                    k++;
                    if (k == num)
                        {
                            img = slide;
                            break;
                        }
                }
        }

    if (bgrp) {
        var output = "<P align=center class='text' accessoryGroups='hsh_text'>";
        output += "<div style='width:100%;background-color:lightblue;border:1px lightgrey solid;padding:2px'>";
        output += "<B>" + img.title + " (" + num + ")</B></div><BR>";
        output += img.legend;
        output += "</P>";
        var tooltip = document.all("diap_tooltip_"+this.id);
        var diap = document.all("diaporama_"+this.id);
        var x = diap.offsetLeft - 5;
        var y = diap.offsetTop + this.height - 5;
        tooltip.innerHTML = output;
        tooltip.style.visibility = "visible";
        tooltip.style.pixelLeft = x;
        tooltip.style.pixelTop = y;
    }

}

function Diaporama_CloseImgInfo() {
    var tooltip = document.all("diap_tooltip_"+this.id);
    tooltip.style.visibility = "hidden";
}
