var rotateTimer;
var rotateDelay = 4000;
var fadeSpeed = 1100;

function swapSlides(){
	clearTimeout(rotateTimer);
	
	var current = $('#rotator .current');
	var next = ( $(current).next('.rotatorSlide').length ? $(current).next('.rotatorSlide') : $('#rotator .rotatorSlide:first') );
	
	$(current).trigger('goAway');
	$(next).trigger('comeBack');
	
	rotateTimer = setTimeout(swapSlides, 4000);
}

$( function() {
	$('#rotator .rotatorSlide').bind('goAway', function(){
		$(this).fadeOut(fadeSpeed, function(){
			$(this).removeClass('current');
		});
	}).bind('comeBack', function(){
		$(this).fadeIn(fadeSpeed, function(){
			$(this).addClass('current');
		});
	});
	
	rotateTimer = setTimeout(swapSlides, 4000);
});