var tx_wtgallery_slideshow = function(els){
	var elements = $$(els);
	if(elements.length > 1){
		var current = null;
		var next = null;
		elements.each(function(el, idx){
			if(!current && el.getStyle('visibility') != 'hidden'){
				current = el;
			}else if(current && !next){
				next = el;
			} 	
		});
		if(!next){
			next = elements[0];
		}
		new Fx.Morph(current, {duration: 500}).start({
			'opacity': 0
		}).chain(function(){
			next.setStyles({
				'visibility': 'visible',
				'opacity': 0
			});
			new Fx.Morph(next, {duration: 1000}).start({
				'opacity': 1
			});
		});
	}
	
}

window.addEvent('domready', function(){
	tx_wtgallery_slideshow.periodical(5000, this, 'div.wtgallery_list');
});