/* Load Events */
function bannerfade(){
	if(document.getElementById('bsw')){
		setTimeout("FadeHide('bsw', 100, 50)", 200);		
		}
	}
function slideshow(){
	if(document.getElementById('slidepic')){
		setTimeout("AutoStepFade('slidepic', 'stepfade', 6500)", 5000);	
		}
	}
/* Functions */
document.onload_array = new Array();
function AddOnload(command){document.onload_array.push(command);}
function DoOnload(){
	for(var i = 0; i < document.onload_array.length; i++) {
		setTimeout(document.onload_array[i], 0);
		}
	}
	
function BilderVorladen() {
	document.SlideImages = new Array();
	if(document.images) {
		for(var i = 0; i < BilderVorladen.arguments.length; i++) {
			document.SlideImages[i] = new Image();
			document.SlideImages[i].src = BilderVorladen.arguments[i];
		}
		return BilderVorladen.arguments.length;
		}
	else{return 0;}
	}
	
function BildWechsel(id, go, picid, changemode) {
    Bild = document.getElementById(id);
	Bild_ID = parseInt(Bild.name);
	if(go == 'next') {
		if(Bild_ID < SlideImgMenge-1) {Bild_ID = Bild_ID+1;}
		else {Bild_ID = 0;}
		}
	else if(go == 'prev') {
		if(Bild_ID > 0) {Bild_ID = Bild_ID-1;}
		else {Bild_ID = SlideImgMenge-1;}
		}
	else if(go == 'switch') {Bild_ID = picid;}
	if(typeof changemode != "undefined"){	if(changemode == 'fade'){	FadeOut(id, 100, 10, Bild_ID);	}	}
	else{Bild.src = document.SlideImages[Bild_ID].src;}
	Bild.name = Bild_ID;
	}

function BildTransparenz(id, opacity) {
	obj = document.getElementById(id);
	opacity = (opacity == 100)?99.999:opacity; // Schützt vor flimmern (in Firefox bspw.)
	obj.style.filter = "alpha(opacity:"+opacity+")"; // IE/Win
	obj.style.KHTMLOpacity = opacity/100; // Safari<1.2, Konqueror
	obj.style.MozOpacity = opacity/100; // Older Mozilla and Firefox
	obj.style.opacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3
	}

var FadeMode = 0;
var FadeDelay = 0;
function AutoStepFade(id, mode, interval) {
	if(AutoStepFade.arguments.length > 2){
		if(mode == 'off'){FadeMode = 0;}
		else if(mode == 'stepfade'){
			if(FadeMode == 0){
				FadeMode = 'stepfade';
				setTimeout("AutoStepFade('"+id+"')", 50);
				}
			FadeDelay = interval;
			}
		}
	else if(FadeMode == 'stepfade'){
		FadeOut(id, 100, 10);
		setTimeout("AutoStepFade('"+id+"')", FadeDelay);
		}	
	}

faderun = true;
function FadeOut(id, opac, timer, picid) {
	if(opac >= 1) {
		opac -= 5;
		faderun = false;
		var newtimer=timer*0.8;
		BildTransparenz(id, opac);
		if(FadeOut.arguments.length == 4){setTimeout("FadeOut('"+id+"',"+opac+","+newtimer+","+picid+")",Math.round(newtimer*100)/100)}
		else{setTimeout("FadeOut('"+id+"',"+opac+","+newtimer+")",Math.round(newtimer*100)/100);}
		}
	else{
		faderun = true;
		if(FadeOut.arguments.length == 4){BildWechsel(id, 'switch', picid);}
		else{BildWechsel(id, 'next');}
		setTimeout("FadeIn('"+id+"', 0, "+timer+")",100);
		}
	}
function FadeIn(id, opac, timer){
	if(opac <= 100) {
		opac += 3;
		var newtimer=timer/0.8;
		if(faderun){BildTransparenz(id, opac);}
		setTimeout("FadeIn('"+id+"',"+opac+","+newtimer+")", Math.round(newtimer*100)/100);
		}
	}
function FadeHide(id, opac, timer){
	if(opac >= 1) {
		opac -= 5;
		BildTransparenz(id, opac);
		setTimeout("FadeHide('"+id+"',"+opac+","+timer+")",Math.round(timer*100)/100);
		}
	}
