var init = function () {
	scanUrls();
	if($$('.slideshow').length) initSlideShow();
}

var scanUrls = function() {	
	$$('a.outside').addEvent('click', function(event) {
		event.stop();
		window.open(this.get('href'));
	});
}

var navSlideShow;
var initSlideShow = function() {
	var caption =  $('caption').set('opacity',0.24);
	var copy = $('copy').set('opacity',0);
	var cursor = $('cursor');
	var navs = $('slideshow').getElements('span');	
	navSlideShow = new SlideShow('slideshow', {
		selector: 'img',
		autoplay: true,
		delay: 6000,
		transition: 'blindLeftFade',
		onPlay : function(){
			cursor.set('class',navs[0].get('class'));			
		},
		onShow: function(data){
			cursor.set('class',navs[data.next.index].get('class'));
			var txt = navs[data.next.index].get('title');
			if(txt!=null)	{
				copy.set('html','&copy; ' + txt).set('opacity',0.6);
			}
			else copy.set('opacity',0);
		}		
	});
};

window.addEvent('domready',init);
