/*

	// -------------------------------------------------------------- //
	// slideshow.js

*/

$(document).ready(function(){

	function slideSwitch(switchSpeed) {
		var $active = $('#slideshow li.active');
	
		if ( $active.length == 0 ) $active = $('#slideshow li:last');
	
		// ordered selection
		var $next = $active.next('li').length ? $active.next('li') : $('#slideshow li:first');
	
		// random selection
	//	var $sibs = $active.siblings();
	//	var rndNum = Math.floor(Math.random() * $sibs.length );
	//	var $next = $($sibs[ rndNum ]);
	   
		$active.addClass('last-active');
	
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, switchSpeed, function() {
				$active.removeClass('active last-active');
			});
	}
	
	/*
	$(function() {
		setInterval("slideSwitch(1000)", 5000);
	});
	*/
	
	// pause when mouseover // does not work
	var playSlideshow = setInterval('slideSwitch(1000)', 4000);
	
	$('#slideshow').hover(function() {
		clearInterval(playSlideshow);
	},
	
	function() {
		playSlideshow;
	});

});
