if (typeof MSE === 'undefined') { MSE = {}; }

MSE.centrifugeRotator = function(options) {
	return (function(options) {
	   var foo = {},
	       $li = $(".centrifugeRotator li"),
	       i = 0, timer = null,
	       params = $.extend(true, {}, MSE.centrifugeRotator.defaults, options);
	   
	   if (!$li.eq(i).is(":visible")) {
	      $li.eq(i).show();
	   }
	   
	   function rotateImage() {
		   timer = setTimeout(function() {
		      $li.eq(i).fadeOut(params.fadeSpeed);
		      i++; if (i >= $li.length) { i = 0; }
		      $li.eq(i).fadeIn(params.fadeSpeed, function() {
		         rotateImage();
		      });
		   }, params.rotateDelay);
		}
		
		foo.start = function(options) {
			if (options) {
				params = $.extend(true, {}, params, options);
			}
			rotateImage();
		}
		
		return foo;
	}(options));
};

MSE.centrifugeRotator.defaults = {
	fadeSpeed: 4000,
	rotateDelay: 7000
};


$(function() {
	var rotator = MSE.centrifugeRotator();
	rotator.start();
});