/*
 * fbSlideShow
 * (c) Federico Besnard
 *
 * BSD license
 *
 * $Id: fbslideshow.js,v 1.4 2010/11/04 20:19:14 Federico.Besnard Exp fico $ 
 */

fbSlideShow = {
	imgsDir : "templates/elcg/images/",
	imgsRoot : "fp",
	imgsExt : ".jpg",
	nImages : 6,
	imgsDelay : 5000,
	imgsStep : 200,
	cx : 0,
	bx : 0,
	dx : 0,
	imgsOpacity : [0.75,0.85,0.90,0.95,0.9999,0.95,0.90,0.85,0.75],
	imgs : new Array(),
	init: function() {
		var i;
		 for (i=0; i < this.nImages; i++){
			this.imgs[i]=new Image();
			this.imgs[i].src=this.imgsDir+this.imgsRoot+i+this.imgsExt;
		 }

		this.showImage();
	},
	dimImage: function( bx ){
		if( document.images.slideshow.style.opacity != undefined ) {
			document.images.slideshow.style.opacity = this.imgsOpacity[ bx ];
		} else {
		/* IE */
			document.images.slideshow.style.filter = "alpha(opacity:"+this.imgsOpacity[ bx ]*100+")";
		}
	},
	setImage: function( ){
			if( document.images == undefined ){
				return;
			}
			switch( this.bx ) {
			case 0:
				document.images.slideshow.src = this.imgs[this.cx].src;
			case 1:
			case 2:
			case 3:
			case 5:
			case 6:
			case 7:
				this.dimImage( this.bx );
				this.bx++;
			break;
			case 4:
				this.dimImage( this.bx );
				if ( this.dx < this.imgsDelay ){
					this.dx += this.imgsStep;
				} else {
					this.bx++;
					this.dx = 0;
				}
			break;
			/* case 8: */
			default:
				this.dimImage( this.bx );
				this.cx++;
				if( this.cx >= this.nImages){
					this.cx = 0;
				}
				this.bx = 0;
			break;
			}
	},
	showImage: function( ){
			this.setImage();
			/* can't use this.showImage() here */
			setTimeout("fbSlideShow.showImage()",this.imgsStep)
	}
}

