
/***********************************************
* Bildwechsel
***********************************************/

var imgIndex = 0;
var repeatInterval = 2500;
 
function startfade() {
	 if((document.getElementById('imgWrapper0') != 'undefined') && (typeof document.getElementById('img0') != 'undefined') && (typeof imgList != 'undefined')){
		imgObj = document.getElementById('img0');
		imgWrap = document.getElementById('imgWrapper0');

		// Hintergrundbild setzen:
		imgWrap.style.backgroundImage = 'url(' + imgObj.src + ')';
		/* debug("Hintergrundbild: "+imgObj.src); */
		fade();
	}
}


function fade(step) {
	// wenn nichts uebergeben wurde, dann step auf 0 setzen:
	step = step || 0;

	// Bild-Deckkraft auf Null setzen und von 0% (step = 0) erhöhen auf 100% (step 100):
	imgObj.style.opacity = step/100;
	imgObj.style.filter = "alpha(opacity=" + step + ")"; // IE
	
	step = step + 2;
	if (step <= 100) window.setTimeout(function () { fade(step); }, 40);
	else {
		// Hintergrundbild austauschen (gleich wie Vordergrund)
		imgWrap.style.backgroundImage = 'url(' + imgObj.src + ')';

		// Bild transparent machen:
		imgObj.style.opacity = 0;
		imgObj.style.filter = "alpha(opacity=0)"; // IE

		// naechstes Bild:
		imgIndex++;
		if(imgIndex >= imgList.length)imgIndex = 0;
		imgObj.src = imgList[imgIndex];

		window.setTimeout('fade()', repeatInterval);
	}
}

function debug(m){
	if(typeof console != 'undefined') console.log(m);
}
