function slideSwitch() {
    var $active = $('#sslides DIV.sslide.active');

    if ( $active.length == 0 ) $active = $('#sslides DIV.sslide:last');
    var $next =  $active.next().length ? $active.next()
        : $('#sslides DIV.sslide:first');
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
            $active.removeClass('active last-active');
        });
}
function slideSwitchBack() {
	var $active = $('#sslides DIV.sslide.active');

    if ( $active.length == 0 ) $active = $('#sslides DIV.sslide:last');
    var $next =  $active.prev().length ? $active.prev()
        : $('#sslides DIV.sslide:last');
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    var playSlideshow =  setInterval( "slideSwitch()", 5000 );
	$('a#arrow-r, a#arrow-l, #sslides').hover(function() {
    clearInterval(playSlideshow);
	},
	function() {
		playSlideshow =  setInterval( "slideSwitch()", 5000 );
	});
	$('a#arrow-r').click(function(e) {
	e.preventDefault();
    clearInterval(playSlideshow);
	slideSwitch();
	});
	$('a#arrow-l').click(function(e) {
	e.preventDefault();
    clearInterval(playSlideshow);
	slideSwitchBack();
	});
});
