(function (){
	jQuery.fn.promoRevolverFade = function(){
		function repeat(str,n){
			return new Array(n+1).join(str);
		}
		return this.each(function(){
			//Variables
			var $wrapper = jQuery('> div', this),
			  	$items = $wrapper.find('> div.promo'),
				$current = $items.filter(':last'),
				singleHeight = $current.innerHeight(),
				$currentPromo = 0;
			//console.log($current);
			
			function fade(){
				jQuery($current).fadeOut(2000,function(){
					shuffle();
				});
			};
			function shuffle(){
				//This function takes the current promo and moves it to the bottom, resetting it's opacity
				jQuery($current).prependTo($wrapper);
				jQuery($current).css('display','block');
				$items = $wrapper.find('> div.promo');
				$current = $items.filter(':last');
			};
			
			jQuery(document).everyTime(7000, function(i) {
                if (!jQuery("#vName").hasClass("focused") ) {
                    if( !jQuery("#vEmail").hasClass("focused") ) {
                        fade();
                    }
                }
			});
			window.fade = fade;
		});
	};
})(jQuery)

