function bbFader(parameter) {

	this.ID=""; // ID des Bildwechslers
	this.preloadList=new Array();
	this.Images=new Array();
	this.Caption=new Array();
	this.CaptionID=""; // Bezeichnung für die Bildbeschreibung
	this.PreloadBack=""; // Hintergrundbild für den Ladevorgang der Bilder
	this.SliderBack=""; // Hintergrundbild für den Slider
	this.MaxWidth=100; // maximale Breite
	this.MaxHeight=100; // maximale Höhe
	this.FaderTime=500; // Zeit in Sekunden, in der überblendet werden soll. 1 Sekunde=1000
	this.FaderStep=20; // Anzahl der Schritte mit denen überblendet werden soll. 1-100
	this.ImagesShuffle=false; // mit zufälligem Bild starten (ein=true, aus=false)
	
	this.imgCurNo=-1; // aktuelles Bild
	this.imgNewNo=0; // neues Bild
	this.imgMax=0; // Anzahl der Bilder
	this.AutoStart=false; // automatischer Bildwechsel (ein=true, aus=false)
	this.AutoInterval=6000; // Interval für automatischen Bildwechsel
	this.autoTimeout=0; // TimerID für automatischen Bildwechsel
	this.fadeTimeout=0; // TimerID für die Überblendung
	this.fadeDelta=1; // Werterhöhung bei jedem Faderschritt
	this.fadeInterval=500; // Timeout-Interval für die Überblendung
	this.fadeOpacity=100; // aktuelle Opacity für die Überblendung


	
	this.PreloadCheck=function() {
		var obj=this;
		for(var i=0; i<this.preloadList.length; i++) {
			if(this.preloadList[i].complete==true) {
				this.preloadList.splice(i, 1);
			}
		}
		if(this.preloadList.length==0) {
			this.Create();
		} else {
			document.getElementById("bbMessage").innerHTML='Noch ' + this.preloadList.length + ' Bilder laden.';
			window.setTimeout(function () { obj.PreloadCheck(); }, 100);
		}
	};
	
	
	
	this.Preload=function() {
		var obj=this;
		// warten bis "slideshow" angesprochen werden kann
		if(!document.getElementById(this.ID)) {
			window.setTimeout(function () { obj.Preload(); }, 100);
			return;
		};
		
		// Fortschritt des Preloader anzeigen
		if(this.PreloadBack) styleBackground=' background:url(' + this.PreloadBack + ') no-repeat center;'; else styleBackground='';
		htmlText='<div style="position:relative; margin:0; padding:0; width:' + this.MaxWidth + 'px; height:' + this.MaxHeight + 'px;' + styleBackground + '">';
		for(var i=0; i<this.imgMax; i++) {
			htmlText+='<table width="' + this.MaxWidth + '" height="' + this.MaxHeight + '" cellpadding="0" cellspacing="0" style="margin:0; padding:0; visibility:visible; position:absolute; left:0px; top:0px;"><tr><td align="center" valign="middle">';
			htmlText+='<p id="bbMessage"></p>';
			htmlText+='</td></tr></table>';
		}
		htmlText+='</div>';
		document.getElementById(this.ID).innerHTML=htmlText;
		
		// Preloader starten
		for(var i=0; i<this.imgMax; i++) {
			this.preloadList[i] = new Image;
			this.preloadList[i].src = this.Images[i];
		}
		this.PreloadCheck();
	};
	
	
	this.Create=function() {
		var obj=this;
		if(this.SliderBack) styleBackground=' background:url(' + this.SliderBack + ') no-repeat center;'; else styleBackground='';
		htmlText='<div style="position:relative; margin:0; padding:0; width:' + this.MaxWidth + 'px; height:' + this.MaxHeight + 'px;' + styleBackground + '">';
		for(var i=0; i<this.imgMax; i++) {
			htmlText+='<table id="' + this.ID + '_img' + i + '" width="' + this.MaxWidth + '" height="' + this.MaxHeight + '" cellpadding="0" cellspacing="0" style="margin:0; padding:0; visibility:hidden; z-index:' + i + '; position:absolute; left:0px; top:0px;"><tr><td align="center" valign="middle">';
			htmlText+='<img src="' + this.Images[i] + '" />';
			htmlText+='</td></tr></table>';
		}
		htmlText+='</div>';
		
		document.getElementById(this.ID).innerHTML=htmlText;
		if(this.ImagesShuffle) var no=Math.round(Math.random() * (this.imgMax-1)); else var no=0;
		
		this.Show(no);
		if(this.AutoStart) this.autoTimeout=window.setTimeout(function () { obj.Auto(); }, this.AutoInterval);
	};
	
	
	
	this.Fade=function() {
		var obj=this;
		this.fadeOpacity+=this.fadeDelta;
		if(this.fadeOpacity>=100) this.fadeOpacity=100;
		document.getElementById(this.ID + "_img"+this.imgNewNo).style.filter="Alpha(Opacity="+this.fadeOpacity+")";
		document.getElementById(this.ID + "_img"+this.imgNewNo).style.MozOpacity=this.fadeOpacity/100;
		document.getElementById(this.ID + "_img"+this.imgNewNo).style.opacity=this.fadeOpacity/100;
		
		if(this.imgCurNo>=0) {
			document.getElementById(this.ID + "_img"+this.imgCurNo).style.filter="Alpha(Opacity="+(100-this.fadeOpacity)+")";
			document.getElementById(this.ID + "_img"+this.imgCurNo).style.MozOpacity=100-(this.fadeOpacity/100);
			document.getElementById(this.ID + "_img"+this.imgCurNo).style.opacity=100-(this.fadeOpacity/100);
		}
	
		if(this.fadeOpacity<100) {
			this.fadeTimeout=window.setTimeout(function () { obj.Fade(); }, this.fadeInterval);
		} else {
			if(this.imgCurNo>=0) document.getElementById(this.ID + "_img"+this.imgCurNo).style.visibility="hidden";		
			this.imgCurNo=this.imgNewNo;
		}
	};
	
	
	
	this.Show=function(no) {
		if(no==this.imgCurNo) return; // gleiches Bild soll angezeigt werden
		if(this.fadeOpacity<100) return; // Fader befindet sich in der Überblendung
		
		if(this.imgCurNo>=this.imgMax) this.imgCurNo=this.imgMax;
		window.clearTimeout(this.fadeTimeout);
		if(this.fadeOpacity<100) {
			if(this.imgCurNo>=0) document.getElementById(this.ID + "_img"+this.imgCurNo).style.visibility="hidden";		
			this.imgCurNo=this.imgNewNo;
		}
		if(this.imgCurNo>=0) document.getElementById(this.ID + "_img"+this.imgCurNo).style.zIndex=1;
		
		this.imgNewNo=no;
		document.getElementById(this.ID + "_img"+no).style.zIndex=2;
		document.getElementById(this.ID + "_img"+no).style.visibility="visible";
		document.getElementById(this.ID + "_img"+no).style.filter="Alpha(Opacity=0)";
		document.getElementById(this.ID + "_img"+no).style.MozOpacity=0;
		document.getElementById(this.ID + "_img"+no).style.opacity=0;
		
		
		this.fadeOpacity=0;
		this.fadeDelta=100/this.FaderStep;
		this.fadeInterval=this.FaderTime/this.FaderStep;
		this.Fade();
		
		if(this.CaptionID) document.getElementById(this.CaptionID).innerHTML=this.Caption[no];
	};
	
	
	
	
	this.Goto=function(no) {
		window.clearTimeout(this.autoTimeout);
		this.AutoStart=false;
		if(no>=this.imgMax) no=this.imgMax-1;
		if(no<0) no=0;
		this.Show(no);
	};
	
	
	this.Next=function() {
		window.clearTimeout(this.autoTimeout);
		this.AutoStart=false;
		if((this.imgCurNo+1)>=this.imgMax) this.Show(0); else this.Show(this.imgCurNo+1);
	};
	
	
	this.Preview=function() {
		window.clearTimeout(this.autoTimeout);
		this.AutoStart=false;
		if((this.imgCurNo-1)<0) this.Show(this.imgMax-1); else this.Show(this.imgCurNo-1);
	};
	
	
	this.Auto=function() {
		var obj=this;
		if(!this.AutoStart) return;
		if((this.imgCurNo+1)>=this.imgMax) this.Show(0); else this.Show(this.imgCurNo+1);
		this.autoTimeout=window.setTimeout(function () { obj.Auto(); }, this.AutoInterval);
	};
	
	
	this.Play=function() {
		this.AutoStart=true;
		this.Auto();
	};
	
	
	this.Stop=function() {
		window.clearTimeout(this.autoTimeout);
		this.AutoStart=false;
	};



	this.Init=function(parameter) {
	
		this.ID=(parameter.ID)?parameter.ID:"imageSlider";
		this.Images=parameter.Images;
		this.Caption=parameter.Caption;
		this.CaptionID=parameter.CaptionID;
		this.PreloadBack=(parameter.PreloadBack)?parameter.PreloadBack:"";
		this.SliderBack=(parameter.SliderBack)?parameter.SliderBack:"";
		this.AutoStart=parameter.AutoStart;
		this.AutoInterval=parameter.AutoInterval;
		this.MaxWidth=(parameter.MaxWidth)?parameter.MaxWidth:100;
		this.MaxHeight=(parameter.MaxHeight)?parameter.MaxHeight:100;
		this.FaderTime=(parameter.FaderTime)?parameter.FaderTime:500;
		this.FaderStep=(parameter.FaderStep)?parameter.FaderStep:20;
		this.ImagesShuffle=parameter.ImagesShuffle;
		
		this.imgMax=this.Images.length;
		
		this.Preload();
	};

	this.Init(parameter);
		
}

