var slideshow = {

	speed: .5,
	delay: 1,
	slide_length: 8,
	id: 1,

	init: function() {

		$('slide_cover').setStyle( { opacity: 0 } );
	
		slideshow.load();
	
	},

	load: function() {
	
		if( slideshow.id == 0 ) return;
	
		slideshow.cover_in();
		
		setTimeout( function() {
		
			$('slide').update( $('slide_' + slideshow.id ).innerHTML );

			 slideshow.cover_out();
			 
			 slideshow.next_id();
			 
			 setTimeout( function() { slideshow.load(); }, slideshow.slide_length * 1000 );

		}, ( slideshow.speed * 1000 ) + ( slideshow.delay * 1000 ) );
	
	},
	
	cover_in: function() {
		
		$('slide_cover').show();
		new Effect.Opacity( $('slide_cover'), { from: 0, to: 1, duration: slideshow.speed } );
	
	},
	
	cover_out: function() {
	
		new Effect.Opacity( $('slide_cover'), { from: 1, to: 0, duration: slideshow.speed } );
		setTimeout( function() { $('slide_cover').hide(); }, slideshow.speed * 1000 );
	
	},
	
	next_id: function() {
	
		if( $( 'slide_' + ( slideshow.id + 1 ) ) )
			slideshow.id = slideshow.id + 1;
		else
			slideshow.id = 0;

	}
	
}

slideshow.init();
