/**
 * Script für Überblendeffekt von Containern auf Startseitenlayouts.
 *
 * @author Lars-Erik Kimmel
 *
 * //SEIBERT/MEDIA GmbH
 * Rheingau Palais
 * Soehnleinstr. 8
 * 65201 Wiesbaden
 * Tel: +49 (0) 611 205 700
 * Fax: +49 (0) 611 205 7070
 * www.seibert-media.net
 */
swapper = {
	container: '#home_teaser>div',
	speed: 2000,
	timeout: 3000
};

(function($) {
	$(function(){
		var num = $(swapper.container).length;
		var iterator = 0;
		
		imgSwap = function () {
			$(swapper.container + ':eq('+(num-iterator-1)+')').fadeOut(
				swapper.speed,
				function () {
					// Z-Index der Elemente in Anzeigereihenfolge neusetzen [1, num]
					// nächste zu oberst, also höherer Z-Index
					$(swapper.container).each(function (index) {
						var zIndex = parseInt($(this).css("zIndex")) % num;
						zIndex++;
						// opacity wird nicht durch show() gesetzt
						$(this).css({ zIndex : zIndex, opacity : 1 }).show();
					});
					
					iterator = (iterator + 1) % num;
					window.setTimeout("imgSwap()", swapper.timeout);
				}
			);
		};
		
		if ($(swapper.container).length > 1) {
			$(swapper.container).each(function (index) {
				// Z-Index in selber Reihenfolge der Elemente anlegen [1, num]
				$(this).css("zIndex", index+1);
			});
			setTimeout("imgSwap()", swapper.timeout);
		}
	});
})(jQuery);