var playSlideshow =  setInterval( "slideSwitch(1)", 4000 );

function slideSwitch(prevOrNext) {
	
    var $active = $('#slideshow DIV.active');
    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    if(prevOrNext == 1)
    {
    	var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');
	}
	else
	{
        var $next =  $active.prev();
	}

    $active.addClass('last-active');
      
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function next() {
	clearInterval(playSlideshow);
	playSlideshow =  setInterval( "slideSwitch(1)", 4000 );
	slideSwitch(1);
}

function prev() {
	clearInterval(playSlideshow);
	playSlideshow =  setInterval( "slideSwitch(1)", 4000 );
	slideSwitch(0);
}