(function($){
	$.fn.slid = function(obj){
		obj = $.extend({
			triggerLeft:".triggerLeft", //左触发器
			triggerRight:".triggerRight", //右触发器
			slider:".list", //滑动项
			speed:500, // //点击后滑动时间
			time:4500, //自动滑动间隔时间
			autoPlay:true //是否自动滑动	
		},obj);
		
		return this.each(function(){
			var container = $(this);
			var size = $(obj.slider).children("li").size();
			var childWidth = $(obj.slider).children("li").eq(0).outerWidth();
			var outerWidth = container.outerWidth();
			$(obj.slider).css({"width":childWidth*size});
			var n = Math.ceil(outerWidth/childWidth);
			
			$(obj.triggerLeft).click(function(){
				$(obj.slider).animate({left:"-="+outerWidth},obj.speed,function(){
					$(this).children("li:lt("+n+")").appendTo($(this));
					$(this).animate({left:"+="+outerWidth},0);
				});
			});	
			
			$(obj.triggerRight).click(function(){
				$(obj.slider).animate({left:"+="+outerWidth},obj.speed,function(){
					var x = size-n-1;
					$(this).children("li:gt("+x+")").prependTo($(this));
					$(this).animate({left:"-="+outerWidth},0);
				});
			});
			
			if(obj.autoPlay){
				var timer = setInterval(function(){$(obj.triggerRight).click();},obj.time);
				$(obj.slider).hover(function(){clearInterval(timer);},function(){timer = setInterval(function(){$(obj.triggerRight).click();},obj.time);});
			}	
		});		
	}
})(jQuery)
