(function($){ 
	$.fn.carusse = function(settings) {
		settings = $.extend({}, $.fn.carusse.defaults, settings);
		// alert(settings.interval);
		
		return this.each(function(){
			var $this = $(this);
			var images = $('img', $this);
			var maxDepth = 1000+images.length;
			var items = new Array();
			var current = 0;
			var ivl;
			
			function place(pos){
				if(!items[pos]){
					return;
				}
				items[pos].css('z-index', 1005);
				$('#in_nana').html(items[pos].attr('title'));
				var nx = pos+1;
				if(!items[nx]){
					nx=0;
				}
				items[nx].css('z-index', 1004).show();
			}
			
			function animate(){
				$('#in_nana').fadeOut(settings.effectSpeed/3, function(){
					
				});
				items[current].fadeOut(settings.effectSpeed, function(){
					current++;
					if(current >= items.length){
						current = 0;
					}
					$('#in_nana').fadeIn(settings.effectSpeed/3)
					place(current);
				});
			}
			
			images.each(function(i, image){
				var ob = $(image);
				ob.css({
					'z-index': 1000,
					'position':'absolute',
					'top':'0',
					'left':'0'
				});
				items.push(ob);
			});
			if(images.length < 2){
				return;
			}
			place(current);
			ivl = setInterval(animate, settings.interval);
		});
		
	};
	
	$.fn.carusse.defaults = {
		interval:10000,
		effectSpeed:1500
	};
	
})(jQuery);
