( function( $ ) {
	$.fn.carousel = function( options ) {
		options = $.extend( {
			auto: false,
			speed: 200,
			easing: null,
			circular: true,
			visible: 3
		}, options || {} );
		var wrapper = $( this );
		var ul = $( '> ul', wrapper );
		var li = $( '> li', ul );
		li.css( { overflow: 'hidden' } ).css( 'float', 'left' );
		ul.css( {
			width: '99999px'
		} );
		wrapper.css( {
			overflow: 'hidden',
			height: li.height(),
			width: options.visible * li.width()
		} );
		function animate() {
			ul.animate(
				{ marginLeft: '-=' + li.width() + 'px' },
				options.speed,
				'linear',
				function() {
					$( li.get( li.size() - 1 ) ).after( li.get( 0 ) );
					ul.css( { marginLeft: 0 } );
					li = $( '> li', ul );
					setTimeout( function() {
						animate();
					}, 0 );
				}
			);
		}
		if ( options.auto ) {
			setTimeout( function() {
				animate();
			}, 0 );
		}
	}
} )( jQuery );
