
$(function() {
	// Speed of the automatic slideshow
	var slideshowSpeed = 6000;
	var interval = '';
	$('#slidebox .navigation a').click(function() {
		goto($(this));
		clearInterval(interval);
		return false;
	});
	
	var goto = function(link) {
		var target = $(link.attr('href'));
		var current = $('#slidebox ul li:visible');
		$('#slidebox .navigation a.active').removeClass('active');
		link.addClass('active');
		current.fadeOut(500);
		target.fadeIn(500);
	};
	
	var next = function() {
		var next = $('#slidebox .navigation a.active').parent().next().children('a');
		if(next.length) {
			goto(next);
		} else {
			goto($('#slidebox .navigation td:first-child a'));
		}
	};
	
	interval = setInterval(function() {
		next();
	}, slideshowSpeed);
})
