(function($){
	$.fn.rotationBox=function(){
		return this.each(function(){
			var $this = $(this);
			var $divs = $(this).find('> div').hide();
			$(this).find('> ul > li > a').click(function(){
				clearTimeout($this.data('timeout'));
				var $div = $('div' + $(this).attr('href') );
				var index = $div.parent().children('div').index($div) + 1;
				$this.data('i', index).rotationNext();
				return false;
			});
			$(this).data('i', 1).rotationNext();
		});
	};
	$.fn.rotationNext=function(){
		var i = $(this).data('i');
		var $this = $(this);
		$(this).find('> div').hide();
		$(this).find('> div:nth-child(' + i + ')').show();
		$(this).find('> ul > li > a').removeClass('selected');
		$(this).find('> ul > li:nth-child(' + i + ') > a').addClass('selected');
		if (++i > $(this).find('> div').length) {
			i = 1;
		}
		$(this).data('i', i);
		$(this).data('timeout', setTimeout(function(){
			$this.rotationNext();
		}, 4000));
	};
})(jQuery);