// Initialise
function init_rotator() {
	
	// Does element exist?
	if(!$('#rotator').length) {
		// if not exit
		return;
	}
	
	// Rotate speed
	var speed = 3000;
	
	// Rotator function
	function rotate(element) {
		
		// Either the next/first <li>
		var $next_li = $(element).next('li').length ? $(element).next('li') : $('#rotator li:first');
		
		// Continue
		function doIt() {
			rotate($next_li);
		}
		
		// fade out <li>
		$(element).fadeOut(speed);
		
		// show next <li>
		$($next_li).fadeIn(speed, function() {
		   // slight delay
		   setTimeout(doIt, speed);
		});
	}
	
	// Hide all but first
	$('#rotator li:first').siblings('li').hide();
	
	// Wait for page load
	$(window).load(function() {
		// Begin rotation
		rotate($('#rotator li:visible:first'));
	});
}

// Initialise
function init_rotatorb() {
	
	// Does element exist?
	if(!$('#rotatorb').length) {
		// if not exit
		return;
	}
	
	// Rotate speed
	var speed = 4000;
	
	// Rotator function
	function rotate(element) {
		
		// Either the next/first <li>
		var $next_li = $(element).next('li').length ? $(element).next('li') : $('#rotatorb li:first');
		
		// Continue
		function doIt() {
			rotate($next_li);
		}
		
		// fade out <li>
		$(element).fadeOut(speed);
		
		// show next <li>
		$($next_li).fadeIn(speed, function() {
		   // slight delay
		   setTimeout(doIt, speed);
		});
	}
	
	// Hide all but first
	$('#rotatorb li:first').siblings('li').hide();
	
	// Wait for page load
	$(window).load(function() {
		// Begin rotation
		rotate($('#rotatorb li:visible:first'));
	});
}

// Kick things off
$(document).ready(function() {
   init_rotator();
   init_rotatorb();
   });
