imgs_container_selector = ".ZWEISPALTIG-BILD-DIASCHAU, .DIASCHAU";

var initDiaschau = function()
{
	containers = $$(imgs_container_selector);
	if (containers.length == 0) return;
	containers.each(function(item, idx){
		
		var imgs = item.getElements('img');
		if (imgs.length == 0) return;
		else runDiaschau(imgs, idx);
		
		})
}

var runDiaschau = function(imgs, idx)
{
	if (imgs.length == 0) return;
	//imgs.setStyle('visibility','hidden');
	imgs.setStyle('opacity','0');
	imgs[0].setStyle('opacity','1');
	
	//get the position
	
	/*
	pos0 = imgs[0].getCoordinates();
	
	imgs.each(function(item,index){
	
		if (index == 0) return;
	
		var removedElement = item.dispose();
		removedElement.inject($('frame'),'after');
	
		//position the other element where it is
		
		item.setPosition({x: pos0.left, y: pos0.top});
		
		item.setStyles({
			position: 'absolute'
		});
		
	});
	*/
	
	var currentIndex = new Array();
	currentIndex[idx] = 0;
	
	var show = function()
	{
		imgs[currentIndex[idx]].fade('out');
		imgs[currentIndex[idx] = currentIndex[idx] < imgs.length - 1 ? currentIndex[idx]+1 : 0].fade('in');
	}
	
	/* start once the page is finished loading */
	window.addEvent('load',function(){
		interval = show.periodical(3000);
	});	
	
}

window.addEvent('domready',initDiaschau);

