;(function($) {
    
	$.slidenstop = {
		direction: 'rtl'	
	}

	$.fn.extend({
		
		slidenstop: function(options) {

	        var options = $.extend($.slidenstop, options);
		
		
	        return this.each(function() {
				var obj         = $(this);
				var newWidth    = 100;
			
				// Create the wrapping div that will do the movement		
				var	objList		= obj.find('ul:first').wrap('<div style="position: absolute;"></div>');						
				var objMover    = obj.find('div:first');
			    
			    // Calculate the width based on the width of the contained LI elements
			    obj.find('li').each(function() {
			    	newWidth += $(this).outerWidth(true);
			    	$(this).clone().appendTo(objList);
			    });
			    
			    objMover.css('width', newWidth *2);
			    
				// Move, pause, rinse, repeat
			    setInterval(function() {
			    	var leftPos = parseInt(objMover.css('marginLeft'));
			    				    		    	
			    	newPos = leftPos - objList.find('li:first').outerWidth(true);
			    	
					objMover.animate({
						marginLeft: newPos +"px"	
					}, 1000, "swing",  function() {			
						
						// When the animation is finished, take the first element and move it to the end
				  		objList.find('li:first').appendTo(objList);
				  		
				  		// Reset the position of the mover
						objMover.css('marginLeft', newPos + objList.find('li:last').outerWidth(true) +'px');
					});
				}, 2000);

	        }); // end return
		} // end function
    }); // end extend
})(jQuery);

