// Initialise
function init_glide() {
	
	/*
	// Does element exist?
	if(!$('#rotator').length) {
		// if not exit
		return;
	}
	*/
	//alert('init');
	// Rotate speed
	var speed = 3000;
	
	// Rotator function
	function rotate(element) {
		
		// Either the next/first <li>
		var $next_div = $(element).next('div').length ? $(element).next('div') : $('#banner-wrapper div:first');
		
		// Continue
		function doIt() {
			rotate($next_div);
		}
		
		// fade out <li>
		//$(element).fadeOut(speed);
		
		$(element).animate({top: '1200'}, 1200);
		
		//alert('hi');
		
		// show next <li>
		$($next_div).animate({top: '0'}, 1200, function() {
		   // slight delay
		   setTimeout(doIt, speed);
		});
		/*
		$($next_li).fadeIn(speed, function() {
		   // slight delay
		   setTimeout(doIt, speed);
		});
		*/
	}
	
	$('#banner-wrapper div:first').siblings('div').css({top: 1200});
	
	// Wait for page load
	$(window).load(function() {
		// Begin rotation
		setTimeout(function() {	rotate($('#banner-wrapper div:first'));}, speed);
	});
}

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