function slideSwitch() {
	
    var $active = $('#slideshow IMG.active');

	if ( $active.length == 0 ) $active = $('#slideshow IMG:first');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');
		
	activeShit($next, 1000);

}

function activeShit($next, $sec){
		
    var $active = $('#slideshow IMG.active');

	if ( $active.length == 0 ) $active = $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, $sec, function() {
            $active.removeClass('active');
            $active.removeClass('last-active');
        });	
}

$(document).ready(function(){
	$('#slideshow IMG:first').addClass('active');
	headline_interval = setInterval( "slideSwitch()", 5000 );
	$("#thumnails_gal a").bind("click", function(event) {
		clearInterval(headline_interval);
		activeShit(
			$(
				$("#slideshow IMG[src*='" + $(this).find('IMG').attr("src") + "']")
			), 300
		);
		return false;

	});

});
