var $elements;
var $current = 0;
var $total = 4;
var $int = null;

$(function(event) {
	$elements = $('#slideshow li');
	$($elements).hide();
	$('#slideshow li:first').show();
	//$total = $elements.size();
	if($total > 0) { 
		interval();
	}
});


function interval() {
	$int = setInterval(updateSlideshow, 5000);
}

function updateSlideshow() {
	clearInterval($int);
	
	// fade out old one 
	//$($elements[$current]).fadeOut('slow', interval);

	var _next = ($current + 1) < 4 ? $current + 1 : 0;
	$($elements[_next]).fadeIn('slow', interval);
	$current = _next;
}
