/**************************************************************************************************
 *
 * Slideshow functions
 *
 **************************************************************************************************/
 
function getByID(id)
{
	if (document.all)
	{
		return document.all(id) ;
	}
	if(document.getElementById)
	{
		return document.getElementById(id) ;
	}
}

function hide(id)
{
	var o = getByID(id) ;
	if (o)
	{
		if (document.all)
		{
			o.display = "none" ;
		}
		if(document.getElementById)
		{
			o.style.display = "none" ;
		}
	}
}

function show(id)
{
	var o = getByID(id) ;
	if (o)
	{
		if (document.all)
		{
			o.display = "visible" ;
		}
		if(document.getElementById)
		{
			o.style.display = "block" ;
		}
	}
}

function Slideshow(bigdst,bigmax,mindst,legend,minnbr) 
{
    this.Idx = 1;					/* Current Element */
    this.Max = bigmax;				/* Total number of Posters */
	this.MinNbr = minnbr;			/* Number of thumbnails per Objet */

	this.BigDst = bigdst;			/* Posters Prefix */
	this.MinDst = mindst;			/* Thumbnails Prefix */
	this.LegDst = legend;			/* Legend Prefix */
	this.OBigDst = getByID(bigdst);	/* Poster object to fill */
	this.OMinDst = getByID(mindst);	/* Thumbnail object to fill */
	this.OLegDst = getByID(legend);	/* Legend object to fill */

	for(i=1;i<=this.Max;i++)
	{	
		hide(this.BigDst + '_' + i);
		hide(this.MinDst + '_' + i);
		hide(this.LegDst + '_' + i);
	}

        this.next = function() {
                this.Idx++;
		if(this.Idx > this.Max)
			this.Idx = 1;
		this.display();
        }

        this.prev = function() {
                this.Idx--;
		if(this.Idx < 1)
			this.Idx = this.Max;
		this.display();
        }

        this.iset = function(i) {
                this.Idx = i;
		this.display();
        }

	this.display = function() {

		/* Replace the Poster content */
		if(this.OBigDst)
		{	OBigSrc = getByID(this.BigDst + '_' + this.Idx);
			this.OBigDst.innerHTML = OBigSrc.innerHTML;
		}

		/* Replace the Legend content */
		if(this.OLegDst)
		{	OLegSrc = getByID(this.LegDst + '_' + this.Idx);
			this.OLegDst.innerHTML = OLegSrc.innerHTML;
		}

		/* Replace thumbnails list content */
		if(this.OMinDst)
		{
			nb=0;
			this.OMinDst.innerHTML = "";
			for(i=this.Idx;nb<=this.MinNbr;i++)
			{	if(i<=this.Max)
				{	nb++;
					OMinScr = getByID(this.MinDst + '_' + i);
					this.OMinDst.innerHTML += OMinScr.innerHTML;
				}
				else
				{	i=0;
				}
			}
		}

	} 
	this.display();
}