/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify
	
	Modified for famab by jhr

***/
var intervalId = null;

function slideSwitch($n) {
    var $active = $jq('#slideshow div.active');

    if ( $active.length == 0 ) $active = $jq('#slideshow div:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $n || ($active.next().length ? $active.next() : $jq('#slideshow div:first'));

    $active.addClass('last-active');
	
	$jq('#forum-nav li').removeClass('selected');
	// set active class for links which are assosiated
	$highlight = $next.find('a').attr('rel');

	if ($highlight) {
		$jq('#' + $highlight).addClass('selected');
	}

    $next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function() {
		$active.removeClass('active last-active');
		
		if (!intervalId) {
			startSlide();
		}
    });

}

function startSlide() {
	intervalId = setInterval( "slideSwitch()", 4000 );
}
function stopSlide() {
	clearInterval(intervalId);
	intervalId = null;
}	
