/*
	Banner Image Ticker
	Kyle Stevenson | New Business Media 2010
*/

$(function(){
	$('a.no-link').click(function(){
		return false;
	});
});

(function($) {

	$.fn.bannerTicker = function(settings) {
		// Allow user to overwrite default Settings
		settings = jQuery.extend({
			duration : 5000
		}, settings);
		
		this.each(function() {
			// Setup Banner Ticker
			var $this = $(this);
			
			// Ignore Single Images
			if ($this.find('a').length < 2) return this;
			
			// Set Timer
			setInterval(function(){
				var $active = $this.find('a.active');

				if ($active.length == 0) {
					$active = $this.find('a:last');
				}

				var $next = ($active.next().length > 0) ? $active.next() : $this.find('a:first');
				$active.addClass('last-active');

				$next.css({opacity: 0.0})
					.addClass('active')
					.animate({opacity: 1.0}, 800, function(){
						$active.removeClass('active last-active');
					});
			}, settings.duration);
		});

		return this;
	};
	
})(jQuery);
