/* ------------------------------------------------------
----------------- JAVASCRIPT SLIDE SHOW -----------------
-------------------------------------------------------*/
function slideSwitch(switchSpeed) {
	$btnActive = $("#rotator_btns .active");
	$btnActive.removeClass('active');
	var $active = $('#rotator DIV.active');
	
	if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
	
	var $next =  $active.next('DIV').length ? $active.next('DIV')
		   : $('#rotator DIV:first');
	
	/*
	var $sibs = $active.siblings();
	var rndNum = Math.floor(Math.random() * $sibs.length );
	var $next = $( $sibs[ rndNum ] );
	*/
	$active.addClass('last-active');
	$next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0}, switchSpeed, function() {
	$active.removeClass('active last-active');
	for (var $i=0; $i<$('#rotator DIV').length; $i ++) {
		if ($('#rotator div:eq(' + $i + ')').hasClass("active")){
			$('#rotator_btns a:eq(' + $i + ')').addClass("active");
		}
	}
	});
}

var $int=setInterval ("slideSwitch(1000)", 5000 );


function slideSelect(slideNum) {
clearInterval($int);
$btnActive = $("#rotator_btns .active");
$btnActive.removeClass('active');
var $selNum = slideNum - 1;
if (!($('#rotator div:eq(' + $selNum + ')').hasClass("active"))) {
	var $next = $('#rotator div:eq(' + $selNum + ')');
	var $active = $("#rotator .active");
	$active.addClass('last-active');
		$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
		$active.removeClass('active last-active');
		for (var $i=0; $i<$('#rotator DIV').length; $i ++) {
			if ($('#rotator div:eq(' + $i + ')').hasClass("active")){
				$('#rotator_btns a:eq(' + $i + ')').addClass("active");
			}
		}
		});
	}
}

