(function($){
	
    $.rotater = function(el, options){

        var base = this;
        base.$el = $(el);
        base.el = el;
        var temp = -1;
        
        base.$el.data("rotater", base);
        
        base.init = function(){
			base.options = $.extend({},$.rotater.defaultOptions, options);
			$("p", base.el).remove();
			base.options.length = base.$el.find('.rotater_item').length;
			
			clearInterval(Interval);
			
			if(base.options.length > 1) {
				base.show();
				Interval = setInterval(base.show,base.options.delay);
			} else if (base.options.length === 1) {
				base.show();
			} else {
				
			}

        };
        
        base.getRand = function(){
        	
			var ran = Math.floor(Math.random()*base.options.length) + 1;
			return ran;
		
        };
        
        base.show = function() {
        	
			ran = base.getRand();

			while (ran == temp){
				ran = base.getRand();
			}; 
			
			temp = ran;
			
        	$(".rotater_item", base.el).hide();
        	$(".rotater_item:nth-child("+ran+")").fadeIn(base.options.animateSpeed);
			
        };
       
        base.init();
    };
    
    $.rotater.defaultOptions = {
    	animateSpeed : 450,
    	delay : 6000
    };
    
    $.fn.rotater = function(options){
        return this.each(function(){
            (new $.rotater(this, options));
        });
    };
    
})(jQuery);
