﻿<!--
/*MSClass (Class Of Marquee Scroll阃氱敤涓嶉棿鏂粴锷↗S灏佽绫? Ver 1.65*\

銆€鍒朵綔镞堕棿:2006-08-29 (Ver 0.5)
銆€鍙戝竷镞堕棿:2006-08-31 (Ver 0.8)
銆€镟存柊镞堕棿:2007-12-28 (Ver 1.65)
銆€镟存柊璇存槑: + 锷犲叆锷熻兘 * 淇銆佸畲鍠?
	1.65.071228
		* 妯悜銆佺旱鍚戞粴锷ㄦ牸寮忚皟鏁?(瑙ｅ喅妯悜婊氩姩鎹㈣镄勯棶棰桡紝镞犻渶鐗规畩璁剧疆)
		* 褰诲簳瑙ｅ喅鐢变簬IE闂瀵艰嚧涓娄笅婊氩姩椤甸溃鐣欑槠镄勯棶棰?(链镟存柊涓昏瑙ｅ喅姝ら棶棰?镒熻阿澶╀笂镄勪功鐢熷弬涓庢祴璇?
	1.6.070131
		+ 绂佹榧犳爣鎺у埗鏆傚仠鎴栫户缁?(灏嗙9涓弬鏁拌缃负-1鎴栬€呭姩镐佽祴链煎皢ScrollSetp璁剧疆涓?1)
		+ 鍒ゆ柇鏄惁鍙互婊氩姩 (鑻ュ唴瀹瑰尯鍩熷皬浜庢樉绀哄尯鍩?鍒栾嚜锷ㄥ彇娑堟粴锷?
		+ 璺宠绷鍒濆鍖栭敊璇?(阆垮厤寮曡捣鍏跺畠婊氩姩镄勫仠姝?
		+ 榛樿链?(闄ゅ鍣↖D蹇呴€夊锛屽叾浠栧弬鏁板潎鍙抵鎹儏鍐佃繘琛岄€夋嫨璁剧疆)
		+ 鍙傛暟锷ㄦ€佽祴链?(鏂瑰悜鍙敤鑻辨枃琛ㄧずtop|up|bottom|down|left|right,浣垮叾镟寸洿瑙伞€佹柟渚?
		* 鏂囧瓧婊氩姩涓嶅嗳纭?(链镟存柊涓昏鐩殑瑙ｅ喅姝ug,镒熻阿锻ㄧ徍鍙备笌娴嬭瘯)
	1.4.061211
		+ 榧犳爣镇仠鏀瑰彉婊氩姩鏂瑰悜 (榧犳爣镇仠鎺у埗宸﹀彸婊氩姩)
		* 鐢变簬鏂囨。涓嬭浇杩囨参钥屽镊磋幏鍙栫殑楂桦害/瀹藉害涓嶅嗳纭?
		* 娴忚鍣ㄥ寸瀹归棶棰?(IE銆丗F銆丱pera銆丯S銆丮YIE)
	1.2.060922
		+ 鎸囧畾锣冨洿闂存珑婊氩姩
		* 绋嫔簭璋冩暣
		* 杩炵画闂存珑婊氩姩锅沧镄勯敊璇?
	1.0.060901
		+ 鍚戜笅銆佸悜鍙虫粴锷?
		+ 寮€濮嬬瓑寰呮椂闂?
		+ 杩炵画婊氩姩
		* 璋冩暣镞堕棿鍗曚綅
		* 婊氩姩璇樊
		* 闅忔満姝诲惊鐜?
		* 锷犲己镐ц兘
		* 绋嫔簭浼桦寲
	0.8.060829
		  缈诲睆涓嶉棿鏂悜涓娿€佸悜宸︽粴锷?

銆€婕旗ず鍦板潃:http://www.popub.net/script/MSClass.html
銆€涓嬭浇鍦板潃:http://www.popub.net/script/MSClass.js

銆€搴旗敤璇存槑:椤甸溃鍖呭惈<script type="text/javascript" src="MSClass.js"></script>
	
	鍒涘缓瀹炰緥:
		//鍙傛暟鐩存帴璧嫔€兼硶
		new Marquee("marquee")
		new Marquee("marquee","top")
		......
		new Marquee("marquee",0,1,760,52)
		new Marquee("marquee","top",1,760,52,50,5000)
		......
		new Marquee("marquee",0,1,760,104,50,5000,3000,52)
		new Marquee("marquee",null,null,760,104,null,5000,null,-1)

		//鍙傛暟锷ㄦ€佽祴链兼硶
		var marquee1 = new Marquee("marquee")	*姝ゅ弬鏁板繀阃?
		marquee1.Direction = "top";	鎴栬€?marquee1.Direction = 0;
		marquee1.Step = 1;
		marquee1.Width = 760;
		marquee1.Height = 52;
		marquee1.Timer = 50;
		marquee1.DelayTime = 5000;
		marquee1.WaitTime = 3000;
		marquee1.ScrollStep = 52;
		marquee1.Start();

	鍙傛暟璇存槑:
		ID		"marquee"	瀹瑰櫒ID		(蹇呴€?
		Direction	(0)		婊氩姩鏂瑰悜	(鍙€?榛樿涓?鍚戜笂婊氩姩) 鍙缃殑链煎寘鎷?0,1,2,3,"top","bottom","left","right" (0鍚戜笂 1鍚戜笅 2鍚戝乏 3鍚戝彸)
		Step		(1)		婊氩姩镄勬闀?(鍙€?榛樿链间负2,鏁板€艰秺澶?婊氩姩瓒婂揩)
		Width		(760)		瀹瑰櫒鍙瀹藉害	(鍙€?榛樿链间负瀹瑰櫒鍒濆璁剧疆镄勫搴?
		Height		(52)		瀹瑰櫒鍙楂桦害	(鍙€?榛樿链间负瀹瑰櫒鍒濆璁剧疆镄勯佩搴?
		Timer		(50)		瀹氭椂鍣?	(鍙€?榛樿链间负30,鏁板€艰秺灏?婊氩姩镄勯€熷害瓒婂揩,1000=1绉?寤鸿涓嶅皬浜?0)
		DelayTime	(5000)		闂存珑锅滈】寤惰繜镞堕棿(鍙€?榛樿涓?涓嶅仠椤?1000=1绉?
		WaitTime	(3000)		寮€濮嬫椂镄勭瓑寰呮椂闂?鍙€?榛樿鎴?涓轰笉绛夊緟,1000=1绉?
		ScrollStep	(52)		闂存珑婊氩姩闂磋窛	(鍙€?榛樿涓虹炕灞忓/楂桦害,璇ユ暟链间笌寤惰繜鍧囦负0鍒欎负榧犳爣镇仠鎺у埗,-1绂佹榧犳爣鎺у埗)

銆€浣跨敤寤鸿:
		1銆佸缓璁洿鎺ヨ祴浜埚鍣ㄧ殑鏄剧ず鍖哄烟镄勫搴﹀拰楂桦害锛屽(<div id="marquee" style="width:760px;height:52px;">......</div>)
		2銆佸缓璁负瀹瑰櫒娣诲姞镙峰纺overflow = auto锛屽(<div id="marquee" style="width:760px;height:52px;overflow:auto;">......</div>)
		3銆佷负浜嗘洿鍑嗙‘镄勮幏鍙栨粴锷ㄥ尯鍩熺殑瀹藉害鍜岄佩搴︼紝璇峰敖鍙兘灏嗗悇婊氩姩鍗曚綅鐩存帴璧嬩篑姝ｇ‘瀹介佩搴?
		4銆佸浜嶵ABLE镙囱镄勬í鍚戞粴锷紝闇€瑕佸TABLE娣诲姞镙峰纺display = inline锛屽(<div id="marquee" style="width:760px;height:52px;overflow:auto;"><table style="display:inline">......</table></div>)
		5銆佸浜庣炕灞忔粴锷ㄦ垨闂存珑婊氩姩锛岃娉ㄦ剰鍚勬粴锷ㄥ崟浣嶉棿镄勯棿璺濓紝鍚屾椂闇€瑕佸瀹瑰櫒镄勫彲瑙嗛佩搴﹀拰鍙瀹藉害锅氩ソ鍑嗙‘镄勮缃紝瀵逛簬鍚勬粴锷ㄥ崟浣嶉棿镄勯棿璺濆彲浠ラ€氲绷璁剧疆琛岄棿璺濇垨钥呭崟鍏冩牸镄勯佩瀹藉害鏉ヨ繘琛岃皟鏁?
		6銆佸浜嶭I镊姩鎹㈣镄勯棶棰樻殏镞舵病链夋洿濂界殑瑙ｅ喅锷炴硶锛屽缓璁皢鍏惰浆鎹㈡垚琛ㄦ牸(TABLE)镄勫舰寮忔潵杈惧埌鍚岀瓑镄勬晥鏋?
		7銆侀拡瀵规í鍚戞粴锷ㄧ殑鏂囧瓧娈佃惤锛屽鏋沧渶链鏄互绌烘牸" "缁撴潫镄勶紝璇峰皢绌烘牸" "杞崲鎴?&nbsp;"
		8銆侀紶镙囨偓锅沧粴锷ㄦ€濇兂婧愯嚜Flash锛屾墍浠ユ湁涓€瀹氱殑灞€闄愭€э纸瀹瑰櫒鍐呬粎鍏佽鐢ㄥ浘鐗?img>鎴栬€呭甫阈炬帴镄勫浘鐗?a><img></a>镄勫舰寮忥紝骞堕渶瑕佺姝㈠叾镊姩鎹㈣锛?

銆€镒熴€€銆€璋?
	澶╀笂镄勪功鐢?QQ:30370740) (IE椤甸溃鐣欑槠镄凚ug) 2007/12/22
	锻ㄧ徍 zhoujun#yuchengtech.com (鏂囧瓧婊氩姩璺宠镄刡ug) 2007/01/31
	镊湰绋嫔簭鍙戝竷浠ユ潵锛屾敹鍒颁笉灏戞湅鍙嬬殑闾欢锛屾彁鍑轰简寰埚镒忚鍜屽缓璁紝镒熻阿澶у镄勬敮鎸侊紒

\***绋嫔簭鍒朵綔/鐗堟潈镓€链?宕旀案绁?333) E-Mail:zhadan007@21cn.com 缃戝潃:http://www.popub.net***/


function Marquee()
{
	this.ID = document.getElementById(arguments[0]);
	if(!this.ID)
	{
		alert("镇ㄨ璁剧疆镄刓"" + arguments[0] + "\"鍒濆鍖栭敊璇痋r\n璇锋镆ユ爣绛绸D璁剧疆鏄惁姝ｇ‘!");
		this.ID = -1;
		return;
	}
	this.Direction = this.Width = this.Height = this.DelayTime = this.WaitTime = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
	this.Step = 1;
	this.Timer = 30;
	this.DirectionArray = {"top":0 , "up":0 , "bottom":1 , "down":1 , "left":2 , "right":3};
	if(typeof arguments[1] == "number" || typeof arguments[1] == "string")this.Direction = arguments[1];
	if(typeof arguments[2] == "number")this.Step = arguments[2];
	if(typeof arguments[3] == "number")this.Width = arguments[3];
	if(typeof arguments[4] == "number")this.Height = arguments[4];
	if(typeof arguments[5] == "number")this.Timer = arguments[5];
	if(typeof arguments[6] == "number")this.DelayTime = arguments[6];
	if(typeof arguments[7] == "number")this.WaitTime = arguments[7];
	if(typeof arguments[8] == "number")this.ScrollStep = arguments[8];
	this.ID.style.overflow = this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
	this.ID.noWrap = true;
	this.IsNotOpera = (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
	if(arguments.length >= 7)this.Start();
}

Marquee.prototype.Start = function()
{
	if(this.ID == -1)return;
	if(this.WaitTime < 800)this.WaitTime = 800;
	if(this.Timer < 20)this.Timer = 20;
	if(this.Width == 0)this.Width = parseInt(this.ID.style.width);
	if(this.Height == 0)this.Height = parseInt(this.ID.style.height);
	if(typeof this.Direction == "string")this.Direction = this.DirectionArray[this.Direction.toString().toLowerCase()];
	this.HalfWidth = Math.round(this.Width / 2);
	this.HalfHeight = Math.round(this.Height / 2);
	this.BakStep = this.Step;
	this.ID.style.width = this.Width + "px";
	this.ID.style.height = this.Height + "px";
	if(typeof this.ScrollStep != "number")this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
	var templateLeft = "<table cellspacing='0' cellpadding='0' style='border-collapse:collapse;display:inline;'><tr><td noWrap=true style='white-space: nowrap;word-break:keep-all;'>MSCLASS_TEMP_HTML</td><td noWrap=true style='white-space: nowrap;word-break:keep-all;'>MSCLASS_TEMP_HTML</td></tr></table>";
	var templateTop = "<table cellspacing='0' cellpadding='0' style='border-collapse:collapse;'><tr><td>MSCLASS_TEMP_HTML</td></tr><tr><td>MSCLASS_TEMP_HTML</td></tr></table>";
	var msobj = this;
	msobj.tempHTML = msobj.ID.innerHTML;
	if(msobj.Direction <= 1)
	{
		msobj.ID.innerHTML = templateTop.replace(/MSCLASS_TEMP_HTML/g,msobj.ID.innerHTML);
	}
	else
	{
		if(msobj.ScrollStep == 0 && msobj.DelayTime == 0)
		{
			msobj.ID.innerHTML += msobj.ID.innerHTML;
		}
		else
		{
			msobj.ID.innerHTML = templateLeft.replace(/MSCLASS_TEMP_HTML/g,msobj.ID.innerHTML);
		}
	}
	var timer = this.Timer;
	var delaytime = this.DelayTime;
	var waittime = this.WaitTime;
	msobj.StartID = function(){msobj.Scroll()}
	msobj.Continue = function()
				{
					if(msobj.MouseOver == 1)
					{
						setTimeout(msobj.Continue,delaytime);
					}
					else
					{	clearInterval(msobj.TimerID);
						msobj.CTL = msobj.Stop = 0;
						msobj.TimerID = setInterval(msobj.StartID,timer);
					}
				}

	msobj.Pause = function()
			{
				msobj.Stop = 1;
				clearInterval(msobj.TimerID);
				setTimeout(msobj.Continue,delaytime);
			}

	msobj.Begin = function()
		{
			msobj.ClientScroll = msobj.Direction > 1 ? msobj.ID.scrollWidth / 2 : msobj.ID.scrollHeight / 2;
			if((msobj.Direction <= 1 && msobj.ClientScroll <= msobj.Height + msobj.Step) || (msobj.Direction > 1 && msobj.ClientScroll <= msobj.Width + msobj.Step))			{
				msobj.ID.innerHTML = msobj.tempHTML;
				delete(msobj.tempHTML);
				return;
			}
			delete(msobj.tempHTML);
			msobj.TimerID = setInterval(msobj.StartID,timer);
			if(msobj.ScrollStep < 0)return;
			msobj.ID.onmousemove = function(event)
						{
							if(msobj.ScrollStep == 0 && msobj.Direction > 1)
							{
								var event = event || window.event;
								if(window.event)
								{
									if(msobj.IsNotOpera)
									{
										msobj.EventLeft = event.srcElement.id == msobj.ID.id ? event.offsetX - msobj.ID.scrollLeft : event.srcElement.offsetLeft - msobj.ID.scrollLeft + event.offsetX;
									}
									else
									{
										msobj.ScrollStep = null;
										return;
									}
								}
								else
								{
									msobj.EventLeft = event.layerX - msobj.ID.scrollLeft;
								}
								msobj.Direction = msobj.EventLeft > msobj.HalfWidth ? 3 : 2;
								msobj.AbsCenter = Math.abs(msobj.HalfWidth - msobj.EventLeft);
								msobj.Step = Math.round(msobj.AbsCenter * (msobj.BakStep*2) / msobj.HalfWidth);
							}
						}
			msobj.ID.onmouseover = function()
						{
							if(msobj.ScrollStep == 0)return;
							msobj.MouseOver = 1;
							clearInterval(msobj.TimerID);
						}
			msobj.ID.onmouseout = function()
						{
							if(msobj.ScrollStep == 0)
							{
								if(msobj.Step == 0)msobj.Step = 1;
								return;
							}
							msobj.MouseOver = 0;
							if(msobj.Stop == 0)
							{
								clearInterval(msobj.TimerID);
								msobj.TimerID = setInterval(msobj.StartID,timer);
							}
						}
		}
	setTimeout(msobj.Begin,waittime);
}

Marquee.prototype.Scroll = function()
{
	switch(this.Direction)
	{
		case 0:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollTop >= this.ClientScroll)
				{
					this.ID.scrollTop -= this.ClientScroll;
				}
				this.ID.scrollTop += this.Step;
			}
		break;

		case 1:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollTop <= 0)
				{
					this.ID.scrollTop += this.ClientScroll;
				}
				this.ID.scrollTop -= this.Step;
			}
		break;

		case 2:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollLeft >= this.ClientScroll)
				{
					this.ID.scrollLeft -= this.ClientScroll;
				}
				this.ID.scrollLeft += this.Step;
			}
		break;

		case 3:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollLeft <= 0)
				{
					this.ID.scrollLeft += this.ClientScroll;
				}
				this.ID.scrollLeft -= this.Step;
			}
		break;
	}
}
//-->
