(function($) {
	$.fn.CreateMoveActions = function(options , callback)
	{
		var settings = {
			direction	: 'left' ,//滚动方向
			speed		: 10 , //滚动速度
			time		: 100 ,//滚动速度
			step		: 1 //步长
		};
	
		if(options) { jQuery.extend(settings, options); };
		
		settings.time= 1000/settings.speed;
		settings.step = 1;
		
		while(settings.time<15)
		{
			settings.time *= 2;
			settings.step *= 2;
		}
		
		//alert(settings.step+","+settings.time);
		
		var container = $(this);
		//jQuery.extend(container, { direction: settings.direction, speed: settings.speed });
		
		//定义临时变量
		var i;
	
		//开?
		container.each(function(){
			var currTab = $(this).parent();
	
			var len , fold ;
			$(this).addClass("_TGL_MoveTable_Item_");
			var htmlstr=currTab.html();
			var html = "";
			$(this).parent().css("overflow","hidden");
			if(settings.direction=='left' || settings.direction=='right')
			{
				fold = currTab.width();
				currTab.html("<div class='_TGL_MoveTable_Big_' style='width:9999px;height:"+currTab.height()+";'></div>");
			}else
			{
				fold = currTab.height();
				currTab.html("<div class='_TGL_MoveTable_Big_' style='height:9999px;width:"+currTab.width()+";'></div>");
			}
			
			currTab.find("._TGL_MoveTable_Big_").html(htmlstr+htmlstr);
			
			if(settings.direction=='left' || settings.direction=='right')
			{
				currTab.find("._TGL_MoveTable_Item_").css("float","left");
				len=currTab.find("._TGL_MoveTable_Item_")[1].offsetLeft-currTab.find("._TGL_MoveTable_Item_")[0].offsetLeft;
			}else
			{
				len=currTab.find("._TGL_MoveTable_Item_")[1].offsetTop-currTab.find("._TGL_MoveTable_Item_")[0].offsetTop;
			}
			
			fold=fold/len+1;
			for(var i=0;i<=fold;i++)
			{
				html+=htmlstr;
			}
			
			currTab.find("._TGL_MoveTable_Big_").html(html);
			currTab.find("._TGL_MoveTable_Item_").css("float","left");
			currTab[0].scrollLeft=0;
			currTab[0].scrollTop=0;
			
			var timer= setInterval(move,settings.time);
			currTab.find("._TGL_MoveTable_Big_").hover(function(){
				clearInterval(timer);						
			},function(){
				timer= setInterval(move,settings.time);																	
			});
			
			function move()
			{
				var tempval;
				if(settings.direction=='left')
				{
					tempval=currTab[0].scrollLeft
					tempval+=settings.step;
					if(tempval > len)
					{
						tempval = tempval-len;
						//alert(tempval)
					}
					currTab[0].scrollLeft = tempval;
				}else if(settings.direction=='right')
				{
					tempval=currTab[0].scrollLeft
					tempval-=settings.step;
					if(tempval <= 0)
					{
						tempval = tempval+len;
						//alert(tempval)
					}
					currTab[0].scrollLeft = tempval;
				}else if(settings.direction=='down')
				{
					tempval=currTab[0].scrollTop
					tempval-=settings.step;
					if(tempval <= 0)
					{
						tempval = tempval+len;
						//alert(tempval)
					}
					currTab[0].scrollTop = tempval;
				}else if(settings.direction=='up')
				{
					tempval=currTab[0].scrollTop
					tempval+=settings.step;
					if(tempval > len)
					{
						tempval = tempval-len;
						//alert(tempval)
					}
					currTab[0].scrollTop = tempval;
				}
			}
			
		});
	}
})(jQuery);
 




































