/*************************************************
**                                              **
**  Vertical List Scroller Plugin               **
**                                              **
**  Author: David Sloane (Simple IT Solutions)  **
**  http://www.simple-it-solutions.com          **
**                                              **
*************************************************/

(function($) {
$.fn.jListScroller = function(options) {
	return this.each(function() {	
		var
			$this = $(this),
			defaults = {
				speed: 400,
				delay: 3000,
				visible_items: 3
			},
			settings = $.extend({}, defaults, options);
		if ($this.children().length > settings.visible_items) {
			$this.children('li').hide();
			for (var i=0; i < settings.visible_items; i++) {
				$this.children('li:eq(' + i + ')').show();
			}
			setInterval(function() {
				var mb = parseInt($this.children('li:first').css('margin-bottom').replace("px", ""));
				$this.children('li:eq(' + settings.visible_items + ')').fadeIn(settings.speed);
				$this.children('li:first')
					.animate({ 
						marginTop : '-' + ($this.children('li:first').outerHeight() + mb),
						opacity: 'hide' },
						settings.speed, 
						function() {
							$this.children('li:first')
							.appendTo($this)
							.css('marginTop', 0) 
						}
					);
			}, settings.delay);
		}
	});
}
})(jQuery);
