// Create a self-invoking anonymous function. That way,
// we're free to use the jQuery dollar symbol anywhere within.

(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);

	  setInterval(function() {
	  	    $this.children('li:first')
	  	    		// Animate it
	  	    		.animate({ 
	  	    			marginTop : '-' + settings.list_item_height,
	  	    		   opacity: 'hide' },
	  	    		   settings.speed, 

	  	    		   function() {
	  	    		   	
	  	    		   	// Get that first list item again. 
	  	 					$this.children('li:first')
	  	 					     .appendTo($this)
	  	 					     .css('marginTop', 0) 
	  	 					     .fadeIn(300);
  		 			  }
 	 			  );
 	  }, settings.delay);
	  });
}

})(jQuery);


