	var diashowTemplate = null;
	var isPlaying = false;
	var diashowContent = '';
	var slider = null;
	var duration = 2;
	var interval = null;
	var aktStyle = '';
	var starting = true;
	var aktEntry = 0;
	function changeStyle(to){
		if(aktStyle == to)
			return;		
	    $('diashowContainer').getChildren().each(function(elem){
		    elem.removeClass(aktStyle);
		    elem.getChildren().each(function(elemx){
			    elemx.removeClass(aktStyle);
			    elemx.getChildren().each(function(elemxx){
				    elemxx.removeClass(aktStyle);
				    elemxx.getChildren().each(function(elemxxx){
					    elemxxx.removeClass(aktStyle);
				    });
			    });
		    });
	    });
	    $('diashowContainer').removeClass(aktStyle);
	    $('layer').removeClass(aktStyle);
	    aktStyle = to;
	    $('diashowContainer').getChildren().each(function(elem){
		    elem.addClass(aktStyle);
		    elem.getChildren().each(function(elemx){
			    elemx.addClass(aktStyle);
			    elemx.getChildren().each(function(elemxx){
				    elemxx.addClass(aktStyle);
				    elemxx.getChildren().each(function(elemxxx){
					    elemxxx.addClass(aktStyle);
				    });
			    });
		    });
	    });
	    $('diashowContainer').addClass(to);
	    $('layer').addClass(to);
	    
	}
	function showNext(dir){
	    window.clearInterval(interval);
	    $('diashowPlayPause').set('src', diashowplay);
	    isPlaying = false;
	    shiftSlideshowArray(dir);
	    $('diashowOut').setStyles({
			'background-image': 'url("' + slideshowimages[aktEntry].src + '")'
		    });
	    $('author').set('html', slideshowimages[aktEntry].author + ', #' + slideshowimages[aktEntry].number);
	    $('counter').set('html', (aktEntry+1) + ' / ' + slideshowimages.length);
	}
	function playSlideshow(){	   
	    if(!isPlaying){
		window.clearInterval(interval);
		$('diashowPlayPause').set('src', diashowplay);
		return;
	    }
	    $('diashowPlayPause').set('src', diashowpause);
	    shiftSlideshowArray('right');
	    $('diashowOut').setStyles({
			'background-image': 'url("' + slideshowimages[aktEntry].src + '")'
		    });
	    $('author').set('html', slideshowimages[aktEntry].author + ', #' + slideshowimages[aktEntry].number);
	    $('counter').set('html', (aktEntry+1) + ' / ' + slideshowimages.length);
    	window.setTimeout(playSlideshow, duration*1000);
	}
	function shiftSlideshowArray(dir){
		if(dir == 'right'){
	    	if(++aktEntry == slideshowimages.length)aktEntry=0;
	    }
	    if(dir == 'left'){
	    	if(--aktEntry == -1)aktEntry = slideshowimages.length-1;
	    }
	}
	function addSpeechBalloon(elem, text){
	    var x = elem.getPosition()['x'];
	    var y = elem.getPosition()['y'];
	    var layer = new Element('div');
	    layer.injectTop(document.body);
	    layer.set({
		'text': text,
		'id': 'speechBalloon'
	    });    
	    layer.setStyles({
		'left': (x-90) - (parseInt(elem.getStyle('padding-left'))) +'px',
		'top': (y-50)+'px',
		'padding-left': '10px',
		'padding-top': '15px',
		'width': '99px',
		'height': '56px',
		'background': 'transparent url("' + diashowtimer + '") no-repeat top center',
		'position': 'absolute',
		'overflow': 'auto',
		'z-index': 5000000
	    });
	}
	function startDiashow(){	
		ContentLayer.openImage('', 550, 420);
		$('indicator').dispose();
		if(diashowTemplate === null)
		{
			diashowTemplate = $('diashowTemplate').get('html');
			$('diashowTemplate').dispose();
		}
		var diashowContent = diashowTemplate;
		new Element('div').set('id', 'layerdiashow').set('html', diashowContent).inject('layer');
	    $('diashowOut').setStyles({
		'background-image': 'url("' + slideshowimages[aktEntry].src + '")'
	    });
	    $('author').set('html', slideshowimages[aktEntry].author + ', #' + slideshowimages[aktEntry].number);
	    $('counter').set('html', slideshowimages[aktEntry].number + ' / ' + slideshowimages.length);	    
		slider = new Slider($('slideshowSlider'), $('slideshowKnob'), {	
			steps: 9000, wheel: true,
			onChange: function(step){	
				if(starting){
					starting = false;
					return;
				}
			    var disposeBalloon = function(){$try(function(){$('speechBalloon').dispose();}, function(){});};
			    var hideBalloon = function(){$try(function(){
				$('speechBalloon').fade(0);
				window.setTimeout(disposeBalloon, 3000);
			    }, function(){});};
			    disposeBalloon();
			    duration = 10 - Math.floor((1000 + step) / 1000);
			    addSpeechBalloon($('slideshowKnob'), duration + ' s' /*+ (duration == 1? '': 'n')*/);
			    window.setTimeout(hideBalloon, 2000);
			}
		}).set(5000);
	    $('diashowPlayPause').addEvents({
		'click': function(){
		    isPlaying = isPlaying? false: true;				
		    playSlideshow();
		}
	    });
	    $('diashowNextLeft').addEvents({
		'click': function(){
		    showNext('left');
		}
	    });
	    $('diashowNextRight').addEvents({
		'click': function(){
		    showNext('right');
		}
	    });
	    $$('.colorChooser').each(function(elem){
		elem.addEvents({
		    'click': function(){
				changeStyle(elem.get('title'));
		    }
		});
	    });
	    $('diashowOut').addEvents({
	    	'click': function(){
	    		isPlaying = false;
	    		window.clearInterval(interval);
	    		window.location = slideshowimages[aktEntry].url;
	    	}
	    });	  
	    if(true || Browser.Engine.trident4){
			$('colorChooserContainer').setStyle('display', 'none');
		}
	    changeStyle('white');
	}
//	window.addEvents({
//	    'domready': function(){
//			diashowContent = $('diashowTemplate').get('html');		
//			$('diashowTemplate').dispose();		
//	    },
//	    'load': function () {
////			startDiashow();
//		}
//	});	
