﻿/*
椹笘浼�
2016.4.7

璋冪敤鏂瑰紡锛�
		<script>
               $(function(){
						
					mswContent(鈥渕swContentId鈥�  鍥哄畾绐楀彛鐨刬d , 鈥渕swLeftId鈥�  宸﹁竟鎸夐挳鐨刬d , 鈥渕swRightId鈥�  鍙宠竟鎸夐挳鐨刬d ,moveLength   绉诲姩璺濈锛坙i鐨勫搴﹀姞涓妉i鐨勯棿璺濓級,moveTimer  绉诲姩鏃堕棿,setTimer  璁℃椂鍣ㄦ椂闂达紙鍗抽殧澶氫箙鎵ц涓€娆″嚱鏁帮級)
							
				})
         </script>







*/
function mswContent(mswContentId,mswLeftId,mswRightId,moveLength,moveTimer,setTimer){
						$("#"+mswContentId+" ul").css({"left":-moveLength})//灏唘l鍒濆瀹氫綅鍒�-moveLength澶勶紱鍘熷洜锛氭帓闄ゅ悜鍙崇偣鍑绘椂鍑虹幇闂幇鍑烘潵鐨勬儏鍐�
						var n = $("#"+mswContentId+" ul li").length;//鑾峰彇li闀垮害
						$("#"+mswContentId+" ul").css({"width":moveLength*n+"px"});//璁剧疆ul鐨勫搴︼紝鏍规嵁li鐨勫搴﹀拰li鐨勯棿璺濅箣鍜屽緱鍑猴紝moveLength = li瀹藉害+li鍗曡竟闂磋窛
						function mm(){
							$("#"+mswContentId+" ul").animate({left:-2*moveLength},moveTimer,function(){//姣忛殧moveTimer寰楁椂闂达紝鍚戝乏绉诲姩2鍊峬oveLength鐨勮窛绂伙紝鍘熷洜锛氬垵濮嬪畾浣嶅埌-moveLength澶勶紝鎵€浠ヨ绉诲姩2鍊嶆墠鑳界湅寰楀嚭鏁堟灉
								$("#"+mswContentId+" ul").css({"left":-moveLength});//姣忎竴娆＄Щ鍔ㄥ悗灏哢L瀹氫綅鍒�0
								$("#"+mswContentId+" ul").children("li:first").insertAfter($("#"+mswContentId+" ul").children("li:last"));//姣忎竴娆″悜宸︾Щ鍔ㄥ悗灏嗙涓€涓猯i鎻掑叆鍒版渶鍚庝竴涓猯i鐨勫悗闈紝鍗冲師绗簩涓彉涓虹涓€涓�
							})
							}
						
						var timer = setInterval(mm,setTimer)//瀹氫箟璁℃椂鍣紝鍗虫瘡闅攕etTimer鎵ц涓€娆m鍑芥暟
						
						$("#"+mswLeftId+"").mouseover(function(){
														clearInterval(timer);//缁堟璁℃椂鍣�
													}).mouseleave(function(){
														timer = setInterval(mm,setTimer);
													}).click(function(){
												
														$("#"+mswContentId+" ul").stop().animate({left:-2*moveLength},moveTimer,function(){
														$("#"+mswContentId+" ul").css({"left":-moveLength});
														$("#"+mswContentId+" ul").children("li:first").insertAfter($("#"+mswContentId+" ul").children("li:last"));
												})
							})
						$("#"+mswRightId+"").mouseover(function(){
														clearInterval(timer);
													}).mouseleave(function(){
														timer = setInterval(mm,setTimer);
													}).click(function(){
														$("#"+mswContentId+" ul").stop().animate({left:0},moveTimer,function(){
														$("#"+mswContentId+" ul").children("li:last").insertBefore($("#"+mswContentId+" ul").children("li:first"));
														$("#"+mswContentId+" ul").css({"left":-moveLength});
													})
							})
						$("#"+mswContentId+" ul li").mouseover(function(){
													clearInterval(timer);
												}).mouseleave(function(){
													timer = setInterval(mm,setTimer);
												})
						
						
						
						
						
						
						
						
						
						
						
}