

	var musicSlideShowPlayer = Class.create(musicPlayer,{
		initialize:function($super, container){
			$super(container);
			this.instID = 'musicSlideshowPlayer_' + parseInt(Math.random()*1000000);
			this.slideShowTimeout = 8000;
			this.fadeOutTimeout = 3.0;
			this.fadeInTimeout = 2.0;
			this.slideIdx = 1;
			this.hasBeenDone = $H({});
			this.doRandom = false;
		},
		
		play : function($super, elem, file){
			$$('.play').each(
					function(elem){
						elem.src = "/images/play.png";
					}
				)
			$$('.trackTitle').each(
					function(elem){
						elem.setStyle('color:white;');
					}
				)

			if ($super(elem, file)){
				if ($('navigation').visible()) {
					new Effect.BlindUp($('navigation'));
					this.slide();
					this.startSlideShow();
				}
				if (elem.className == 'trackTitle'){
					elem.setStyle('color:#666666;');
					$(elem.parentNode).select('.play')[0].src = "/images/pauze.png";
				}else{
					elem.src = "/images/pauze.png";
					$(elem.parentNode).select('.trackTitle')[0].setStyle('color:#666666;');
				}
			}else{
				this.resetSlideShow();
			}
		},
		
		startSlideShow : function(){
			this.interval = setInterval(
					this.slide.bind(this),
					this.slideShowTimeout
				)
		},
		
		getSlideImg : function(){
			if (this.doRandom){
				var randVal = this.getRandom();
				return randVal;
			}else{
				var idx = this.slideIdx;
				this.slideIdx++;
				if (this.slideIdx > slideCount) this.slideIdx = 1; 
				return idx;
			}
		},
		
		getRandom : function(){
			var randVal = parseInt(Math.random()*(slideCount));
			if (this.hasBeenDone.keys().length == (slideCount - 4)) this.hasBeenDone = $H({}); 
			if (this.hasBeenDone.get(randVal)) return this.getRandom();
			this.hasBeenDone.set(randVal, true);
			return randVal;
		},
		
		slide : function(){
			if (!this.nextImg){
				this.nextImg = new Element('img', {src:'/images/slides/' + this.getSlideImg() + '.jpg'});
				this.nextImg.hide();
				$('slideShow').insert(this.nextImg);
			}
			var currImg = $('slideShow').select('img')[0];
			var newImg = $(this.nextImg);
			new Effect.Fade(currImg, {duration:this.fadeOutTimeout});

			setTimeout(
				(function(){
					new Effect.Appear(newImg, {duration:this.fadeInTimeout});
				}).bind(this),
				(this.fadeOutTimeout + 1500)
			)
			
			this.maximize(newImg);
			
			setTimeout(
				(function(){
					currImg.remove();
				}).bind(this),
				(this.fadeOutTimeout + 1500)
			)

			this.nextImg = new Element('img', {src:'/images/slides/' + this.getSlideImg() + '.jpg'});
			this.nextImg.hide();
			$('slideShow').insert(this.nextImg);
			
		},
		
		resetSlideShow : function(){
			var currImg = $('slideShow').select('img')[0];
			
			var newImg = new Element('img', {src:'/images/music_bg.jpg'});
//			newImg.setStyle('position:absolute;left:0px;top:0px;');
			newImg.hide();
			
			$('slideShow').insert(newImg);

			new Effect.Fade(currImg, {duration:this.fadeOutTimeout});

			setTimeout(
				(function(){
					new Effect.Appear(newImg, {duration:this.fadeInTimeout});
				}).bind(this),
				(this.fadeOutTimeout + 1500)
			)
			
			this.maximize(newImg);
			
			setTimeout(
				(function(){
					currImg.remove();
				}).bind(this),
				(this.fadeOutTimeout + 1500)
			)
			clearInterval(this.interval);
			
			setTimeout(
					(function(){
						new Effect.BlindDown($('navigation'));
						setTimeout(
								function(){
									navigation.centerNav()
									navigation.container.setStyle('bottom:64px;');
								}
							, 1200);
					}).bind(this),
					1500
				)			

			this.nextImg.remove();
		},
		
		maximize : function(img){
			$$('.slideshowContainer')[0].setStyle('width:' + $(document.body).getWidth() + "px;");
			if (!img) img = $$('.slideshowContainer img')[0];
			img.setStyle('height:auto;width:100%;');

			// set overflow of musicmenu
			if (parseInt($(document.body).getWidth()) < parseInt($('musicMenu').getWidth()) ){
				$('musicMenuScoller').setStyle('width:'+parseInt($(document.body).getWidth())+'px;overflow:scroll;overflow-y:hidden;');
				$('musicMenu').setStyle('bottom:-10px');
			}else{
				$('musicMenuScoller').setStyle('width:100%;overflow:hidden;');
				$('musicMenu').setStyle('bottom:-3px');
			}
		},
		
		playerTimeCallback : function(position, duration){
			this.currTime = position;
			this.duration = duration;
			if (this.currTime >= this.duration || (this.currTime >= ( this.duration - 0.3) ) ){
				$$('.play').each(
						function(elem){
							elem.src = "/images/play.png";
						}
					)
				setTimeout(					
						(function(){
							this.resetSlideShow()
						}).bind(this),
						1500);
			}
		}
		
	})
