window.addEvent('domready', function() {

	$$('.template_image_container').each(function(el) {
		
		//alleen slideshow tonen als er meerdere afbeeldingen in container staan
		children = el.getChildren();
		if (children.length == 1)
			return;
		
		//volgende afbeelding tonen
		var slideShow = function() {
		
			//slideshow herstarten
			if (this[this.length-1].getStyle('z-index') == 999) {
				for (x = 0; x < this.length; x++) 
					this[x].setStyle('z-index', 999 - x);
	
				return;
			}
			
			//volgende afbeelding tonen
			for (x = 0; x < this.length; x++) {
				
				currentZindex = this[x].getStyle('z-index');
				
				if (currentZindex == 999)
					this[x].setStyle('z-index',  currentZindex - this.length + 1);	
				else 
					this[x].setStyle('z-index', currentZindex.toInt() + 1);
				
			}
		}
		
		//slideshow starten
		slideShow.periodical(2000, children);
			
	});	
});

