/***
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = jQuery('#slideshow .active');
    var $marker = jQuery('.markers .active_li');

    if ( $active.length == 0 ) $active = jQuery('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
	var $next = '';
	var $activeMarker = '';

	if ($active.next().length) {
		$next = $active.next();
		$activeMarker = $marker.next();
	} else {
		$next = jQuery('#slideshow DIV:first');
		$activeMarker = jQuery('.markers li:first');
	}
    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = jQuery( $sibs[ rndNum ] );


    $active.addClass('last-active');
    jQuery('.markers').find('li').removeClass('active_li').addClass('not_active');
    $activeMarker.removeClass('not_active').addClass('active_li');

    $next.addClass('active').css('display', '');
	    $active.removeClass('active last-active').css('display', 'none');
}

jQuery(function() {
	jQuery('<ul class="markers"></ul>').insertAfter('#slideshow');
	var $countFrames = jQuery('#slideshow').find('div.slideshow_other').length;
	jQuery('.markers').append('<li class="active_li"></li>');
	for (var $i = 0; $i < $countFrames - 1; $i++) {
		jQuery('.markers').append('<li class="not_active"></li>');
	}

        jQuery('.slideshow_other').hide();
        jQuery('#slideshow .active').show();
        jQuery('div.slidebox').show();
    setInterval( "slideSwitch()", 10000 );
});


