window.addEvent('domready', function(){
	//Setup photos slideshow
	var SlideShow = new SimpleCarousel($('slideshow'), $$('#slideshow div.slideshowImage img'), null, {
		startIndex:			0,
		slideInterval:		5000,
		rotateAction:		'click',
		autoplay:			true,
		onShowSlide:		function(index){
			function countImg(){
				var nImg = 0
				$$('#slideshow div.slideshowImage img').each(function(){ nImg++ })
				return (nImg - 1)
			}
			var newIndex = (index - 1) < (0) ? (countImg()) : (index - 1)
			$('ssPrv').store('index', newIndex)
		}
	});
	
	$('ssPrv').addEvent('click', function(){
		SlideShow.stop()
		var newIndex = this.retrieve('index', 0).toInt()
		SlideShow.showSlide(newIndex)
	})
	
	$('play-pause').addEvent('click', function(){
		var status = this.getElement('img').getProperty('alt')
		if (status == 'pause'){
			SlideShow.stop()
			this.getElement('img').setProperties({'src':'../img/player/play.png', 'alt':'play'})
		} else if (status == 'play'){
			this.getElement('img').setProperties({'src':'../img/player/pause.png', 'alt':'pause'})
			SlideShow.autoplay()
		}
		this.fade('hide').fade('in')
	})
	
	$('ssNxt').addEvent('click', function(){
		SlideShow.stop()
		SlideShow.rotate()
	})
	//
})
