(function($){
	$.fn.ticksmooth = function(options) {
		
		var defaults = {
			speed: 0.08,
			label: false,
		}
		
		var options = $.extend(defaults, options);

		return this.each(function(){
			
			$this = $(this);
			
			function get_width(){
				var width = 0;
				$this.find('li').each(function(i) {
					console.log($(this).width());
					
					width += $(this).find('li').eq(i).width();
				});
				console.log(width);
				
				return 300;
			}
			
			$this.wrapAll("<div></div>")
			.parent()
			.attr('class', 'movethis')
			.css({
				position: 'relative',
				overflow:'hidden',
			})
			.find('ul').css({
				width:"6500px",
				position: 'relative',
				left: '0px',
				top: '0px',
				left:$this.parent().width(),
			})
			.find('li').css({
				float: 'left',
				'margin-left':'10px'
			});
			
			if(options.label){
				$this.parent('.movethis')
					.wrapAll("<div></div>")
					.parent()
					.css({
						position:'relative'
					})
					.append('<span class="ticker_label"></span>')
					.find('.ticker_label')
					.css({
						position:'absolute',
						top:'0px',
						left:'0px'
					})
					.text(options.label)
					.css(options.label_css);
			}

			function endless(elem){
				$(elem).animate({
					left:'-'+6500,
				},{
					easing: "linear",
					duration: $(elem).parent().width()/options.speed,
					complete: function() {
						$(elem).css('left',$(elem).parent().width());
						endless($(elem));	
					}
				});
			};
			endless($this);	
		});
	};
})(jQuery);