(function($){
	$.fn.carousel = function(){
		return this.each(function(){
			
			// grab all divs in the carousel and hide them
			var $carousel = $('>div', this).hide();
			// set $current item to be the first div...
			var $current = $carousel.filter(':first');
			// fade in the current div
			$current.fadeIn();
			
			// the main function
			crossfade = function(){
				$current.fadeOut(1000);
				$current = ($current.next('div').length == 0 ) ? $carousel.filter(':first') : $current.next();
				$current.fadeIn(1000);
			}
			
			// start the carousel for the first time
			if ($carousel.length > 1) timer = window.setInterval(crossfade, 6000);
		});
	}
})(jQuery);

$(document).ready(function(){
	$('#carousel').carousel();
});
