// JavaScript Document
/*** 
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($direction,$animate) {
	
	// SET DEFAULTS
	$direction = typeof($direction) != 'undefined' ? $direction : 1;
	$animate = typeof($animate) != 'undefined' ? $animate : 800;
	
    var $active_banner = $('#imageshow div.banner.active');

    //if ( $active_banner.length == 0 ) $active_banner = $('#imageshow div.banner:last');
	
	if($direction > 0){
		if ( $active_banner.next('#imageshow div.banner').length == 0 ){
			var $next_banner =  $('#imageshow div.banner:first');
		}else{
			var $next_banner =  $active_banner.next('#imageshow div.banner');
		}
	}else{
		if ( $active_banner.prev('#imageshow div.banner').length == 0 ){
			var $next_banner =  $('#imageshow div.banner:last');
		}else{
			var $next_banner =  $active_banner.prev('#imageshow div.banner');
		}
	}

    $active_banner.addClass('last-active');

    $next_banner.css({opacity: 0.0}).addClass('active')
        .animate({opacity: 1.0}, $animate /* if paging disable animate */, function() {
            $active_banner.removeClass("active").removeClass("last-active");
        });
		
}
