(function( $ ){
  $.fn.promoanimator = function() {

	this.each(function() {
		
		this.interval = 5000 ;
		this.easing = 'easeOutExpo' ;
		this.duration = 400 ;
		this.pause = 500 ;
		this.pointer = 0 ;
		this.timer ;
		
		
		this.images = new Array() ;
		var self = this ;
		
		$(this).children('a').each(function() {
			
			self.images.push($(this)) ;
			
			$(this).css({display: 'none', height: 0}) ;
			
		}) ;
		
		$(this).children('a:first').css({display: 'block', height: 164}) ;
		
		this.animate = function()
		{
			
			// hide current
			self.images[self.pointer].stop(true).animate({height: 0}, self.duration, self.easing).queue(function() {
				$(this).css({display: 'none'}) ;
			
			
				// increase pointer
				self.pointer = self.pointer + 1 ;
				if(self.pointer > (self.images.length)-1)
				{
					self.pointer = 0 ;
				}
			
				// show new
				self.images[self.pointer].css({display: 'block'}) ;
				self.images[self.pointer].stop(true).delay(self.pause).animate({height: 164}, self.duration, self.easing).queue(function() {
				
					self.timer = setTimeout(self.animate, self.interval) ;
				
				}) ;
			
			}) ;
			
		}
		
		if(this.images.length > 1)
		{
			this.timer = setTimeout(this.animate, this.interval) ;
		}
		
	}) ;

  };
})( jQuery );
