
(function ($){

	$.fn.ticker = function(options) {
		settings = jQuery.extend({
			
		}, options);
		
		return new $.ticker(this, settings);
	};
	
	$.ticker = function(el, settings) {
	
		var $ruler = $('<span></span>');
		
		$ruler.css({ "whitespace": "no-wrap", "visibility" : "hidden", "font-size" : el.css("font-size")});
		
		$ruler.html(el.text());
		$("body").append($ruler);
		
		var width = $ruler.get(0).offsetWidth ;
		width += width/2;
		var count = el.children().length;
		var parentwidth = width ;//* (count +1);
		
		var w = $(document).width();
		if (width < w)
			width = w;
		
		el.css( {  "position": "relative", "border" : "0px solid red", "overflow": "hidden" });
		
		el.children().each( function()
		{
			$ruler.css( { "width" : width + "px", "position" : "absolute", "float" : "left", "display": "block" } );
		});
		
		
		
		moveRight();
		
		function slideLeft()
		{
			el.children().animate( { "margin-left" : -width + "px" }, 20000, "linear", function() { 
				moveRight();
			} );	
		};
		
		function moveRight()
		{
			el.children().css({"margin-left" : (width/2) + "px" , "width" : width + "px" });
			slideLeft();
		};
		
		
	};
})(jQuery);
