(function($) { 
	jQuery.fn.newsTicker = function(options){
		var defaults = {
			easing		: 'swing',
			delay		: 6000,
			scrollTime	: 1000,
			appearTime	: 1000
		};

		options = $.extend(defaults, options);
		
		return $(this).each(function() {
			var w = 0;
			$('li', this).each(function(){w += $(this).width();});
			var cont = $(this);
			
			cont.width(w+1000);
			$('<div></div>')
			.css({overflow:'hidden', width:cont.parent().width() - $(cont.parent().children()[0]).width() - 2*parseInt($(cont.parent().children()[0]).css('padding-left')) + 'px'})
			.appendTo(cont.parent())
			.append(cont)
			.append('<div style="clear:both;"></div>');
			
			scroll();
			
			function show() {
				cont.css({marginLeft:'0px'});
				cont.children().first()
				.hide()
				.fadeIn(options.appearTime)
				.appendTo(cont)
				.ready(scroll);				
			}
			function scroll() {
				cont
				.delay(options.delay)
				.animate({marginLeft:"-" + cont.children().first().width() + "px"}, options.scrollTime, show);
			}
		});
	};
})(jQuery);
