/* ------------------------------------------------------
----------------- JAVASCRIPT SLIDE SHOW -----------------
-------------------------------------------------------*/

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

function slideSwitch2(switchSpeed) {
	//$btnActive = jQuery("#rotator_btns .active");
	//$btnActive.removeClass('active');
	var $active = jQuery('#rotator2 DIV.active');
	
	if ( $active.length == 0 ) $active = jQuery('#rotator2 DIV:last');
	
	var $next =  $active.next('DIV').length ? $active.next('DIV')
		   : jQuery('#rotator2 DIV:first');
	
	/*
	var $sibs = $active.siblings();
	var rndNum = Math.floor(Math.random() * $sibs.length );
	var $next = jQuery( $sibs[ rndNum ] );
	*/
	$active.css({opacity: 1.0})
	.addClass('last-active')
	.animate({opacity: 0.0});
	
	$next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0});
	
	$active.removeClass('active last-active');
}

var $int=setInterval ("slideSwitch(1000)", 8000 );
var $int2=setInterval ("slideSwitch2(1000)", 8000 );

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

function slideSelect2(slideNum) {
clearInterval($int);
clearInterval($int2);
//$btnActive = jQuery("#rotator_btns .active");
//$btnActive.removeClass('active');
var $selNum = slideNum - 1;
if (!(jQuery('#rotator2 div:eq(' + $selNum + ')').hasClass("active"))) {
	var $next = jQuery('#rotator2 div:eq(' + $selNum + ')');
	var $active = jQuery("#rotator2 .active");
	$active.css({opacity: 1.0})
	.addClass('last-active')
	.animate({opacity: 0.0});
	
		$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0});
		$active.removeClass('active last-active');
	}
}

