// Original Author: Jeffrey Way (http://net.tutsplus.com/author/jeffreyway/)
// Link: http://net.tutsplus.com/videos/screencasts/how-to-build-a-super-duper-news-scroller/

// Extended by Kyle Stevenson (Ticker now Pauses on Hover)
// New Business Media, 2009 - http://nbm.com.au/

(function($) {

$.fn.newsScroll = function(options) {

	return this.each(function() {
		
		var  
			$this = $(this),   

			defaults = {  
				speed: 400,   
				delay: 3000,   
				list_item_height: $this.children('li').outerHeight()   
			},  

			settings = $.extend({}, defaults, options),
			
			timer = false;

		// On MouseOut (Start)
		$this.mouseout(function() {
			timer = setInterval(function() {
				$this.children('li:first')
					.animate({
							marginTop : '-' + settings.list_item_height,
							opacity: 'hide'
					},

					settings.speed,

					function() {
						$this
							.children('li:first')
							.appendTo($this)
							.css('marginTop', 0)
							.fadeIn(300);
					}
				); // end animate
			}, settings.delay);
		}).mouseout(); // Start Ticker by default
		
		// On MouseOver (Pause)
		$this.mouseover(function() {
			clearInterval(timer);
		});
	});
}

})(jQuery);


