/***
    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(id) {
	var $animating = $('#slideshow').hasClass('animating');
	if (!$animating) {
		$('#slideshow').addClass('animating');
		var $active = $('#slideshow .active');
		var $active_btn = $('.switcher .active');

		if ( $active.length == 0 ) $active = $('#slideshow .slidebanner:last');


		if (id) {
			if (id == $('.switcher .active a').attr('rel')) return false;
			var $next =  $('#slideshow .slidebanner:nth-child(' + id + ')');
			var $next_btn =  $('.switcher li:nth-child(' + id + ')');
		} else {
			var $next =  $active.next().length ? $active.next() : $('#slideshow .slidebanner:first');
			var $next_btn = $active_btn.next().length ? $active_btn.next() : $('.switcher li:first');
		}

		$active.addClass('last-active');
		$active_btn.addClass('last-active');

		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active.removeClass('active last-active');
				$('#slideshow').removeClass('animating');
			});
		$active_btn.removeClass('active last-active');
		$next_btn.addClass('active');
		
		update_switches();
		
	}

}
function update_switches()
{
	$('.switcher img').attr('src', '/images/new/slider_icon.png');
	$('.switcher li.active img').attr('src', '/images/new/slider_icon_current.png');
}
