var
	fadeSpeed = 1000,
	rotateSpeed = 3000,
	rotateThis = '.rotator img';

function theRotator() {
	$(rotateThis).hide();
	$(rotateThis+':first').addClass('show').show();
	setInterval('rotate()', rotateSpeed);
};

function rotate() {
	var current = ($(rotateThis+'.show') ? $(rotateThis+'.show') : $(rotateThis+':first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $(rotateThis+':first') : current.next()) : $(rotateThis+':first'));
	next.fadeOut(fadeSpeed).addClass('show').fadeIn(fadeSpeed);
	current.fadeOut(fadeSpeed).removeClass('show');
};

function rotatorHeight(){
	$('.rotator').css({height: $(rotateThis).height() + 'px'});
};

$(window).resize(function(){
	rotatorHeight();
});

$(window).load(function(){
	rotatorHeight();
});

$(function(){	
	theRotator();	
});
