/**
 * Rotates elements insite parent ( highlight box).

Required styles:

parent child{
	display: none;
}
parent child:first-child {
	display: block;
}

Structure:
<parent>
	<child>
	<child>
</parent>
 */
(function( $ ){
	$.fn.rotating_banner = function( options ) {
		var settings = {
			'time': 1000, // rotation time in ms
			'child': 'div', // elements to be rotated
			'effect': ' ' // fade | slide | no effect (default)
		};
		
		if (options) {
			$.extend( settings, options);
		}

		$this = $(this);
		var elements = $this.children(settings['child']);
		var counterMax = $this.children(settings['child']).length;
		var counter = 0;

		if (counterMax > 1) {
			startRotation();
		}

		function startRotation() {
				rotation = setInterval(function(){replaceElement()}, settings['time']);
		}

		function replaceElement(){
			if (settings['effect'] == 'slide') {
				elements.eq(counter++).slideUp(500, function() {
					if (counter >= counterMax){
						counter = 0;
					}
					elements.eq(counter).slideDown();
				});
			} else if (settings['effect'] == 'fade') {
				elements.eq(counter++).fadeOut(500, function() {
					if (counter >= counterMax){
						counter = 0;
					}
					elements.eq(counter).fadeIn();
				});
			} else {
				elements.eq(counter++).hide(500, function() {
					if (counter >= counterMax){
						counter = 0;
					}
					elements.eq(counter).show();
				});
			}
		}

  };
})( jQuery );



