var sMoveDiv = "";
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 30;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;

function MoveDiv(sType)
{
	width = document.body.clientWidth;
	height = document.body.clientHeight;
	Hoffset = mObj.offsetHeight;
	Woffset = mObj.offsetWidth;
	if (sType == "1")
	{
		document.all.mObj.style.pixelTop=document.body.scrollTop+(height/3);
		document.all.mObj.style.pixelLeft=10;
	}
	else if (sType == "2")
	{
		document.all.mObj.style.pixelTop=document.body.scrollTop+(height/3);
		document.all.mObj.style.pixelLeft=width -Woffset-10;
	}
	else
	{
		mObj.style.left = xPos + document.body.scrollLeft;
		mObj.style.top = yPos + document.body.scrollTop;
		if (yon) 
		{
			yPos = yPos + step;
		}
		else 
		{
			yPos = yPos - step;
		}
		if (yPos < 0) 
		{
			yon = 1;
			yPos = 0;
		}
		if (yPos >= (height - Hoffset)) 
		{
			yon = 0;
			yPos = (height - Hoffset);
		}
		if (xon) 
		{
			xPos = xPos + step;
		}
		else 
		{
			xPos = xPos - step;
		}
		if (xPos < 0) 
		{
			xon = 1;
			xPos = 0;
		}
		if (xPos >= (width - Woffset)) 
		{
			xon = 0;
			xPos = (width - Woffset);
		}
	}
}

function MovePic(sFile, sUrl, sTitle, sType, sWidth, sHeight)
{
	var sHtml = "<div id='mObj' style='position:absolute;'>";
	if (sUrl!="") {sHtml = sHtml +"<a href='"+sUrl+"' target='_blank' title='"+sTitle+"'>";}

	i=sFile.length;
	tem=sFile.substring(i-3,i);
	tem=tem.toLowerCase();
	
	if ((tem=="jpg") || (tem=="gif")) 
	{
		sHtml = sHtml +"<img src='"+sFile+"' border='0' alt='"+sTitle+"' width='"+ sWidth+"' height='"+sHeight+"'>";
	}
	else if ((tem=="swf")) 
	{
		sHtml = sHtml +"<embed src='"+sFile+"' quality=high type='application/x-shockwave-flash' width='"+sWidth+"' height='"+sHeight+"'></embed>";
	}
	else 
	{
		sHtml = sHtml +"<a href='"+sFile+"'>下载该文件</a>";
    }	
	if (sUrl!="") {sHtml = sHtml +"</a>";}
	sHtml = sHtml +"</div>";
	document.write(sHtml);
    mObj.visibility = "visible";
	var interval = setInterval("MoveDiv('"+sType+"');", delay);
}


function OpenWnd(wd,hd) 
{
	var turl = "open.asp";
	var tt=(screen.height-hd)/2;
	var ll=(screen.width-wd)/2;
	var winn=window.open(turl,"","scrollbars=no,resizable=no,status=no,width="+wd+",height="+hd+",top="+tt+",left="+ll);
	winn.focus();
	return false;
}

// 多张图片轮流显示
var PlayFileList = new Array();
var PlayNum = -1;
var PlayObj = null;
var TextObj = null;
var PlayKey = 0;
function playlist(sPlayObj, sTextObj, sData)
{
	PlayObj = sPlayObj;
	TextObj = sTextObj;
	PlayFileList = sData.split('‖');
	for (var i=0;i<PlayFileList.length;i++)
	{
		PlayFileList[i] = PlayFileList[i].split('々');
	}
	if (PlayFileList.length>0) playnext();
}

function playnext()
{
	PlayNum++;
	if (PlayNum>=PlayFileList.length) PlayNum = 0;
	if (PlayKey == 0)
	{
		PlayKey = 1;
	}
	else if (document.all)
	{
		PlayObj.filters.revealTrans.Transition=23;
		PlayObj.filters.revealTrans.apply();
        	PlayObj.filters.revealTrans.play();
	}
	PlayObj.src=PlayFileList[PlayNum][0];
	TextObj.innerHTML=PlayFileList[PlayNum][1]; 
	theTimer=setTimeout("playnext()", 4500);	
}

function playopen()
{
	if (PlayNum<0) return false;
	var CurUrl = PlayFileList[PlayNum][2];
	if (CurUrl != '') window.open(CurUrl, '_blank');
	return false;
}




/* 滚动 样式类
		容器ID
		 0		向上滚动(0向上 1向下 2向左 3向右)
		 1		滚动的步长(数值越大,滚动越快)
		 760		容器可视宽度
		 52		容器可视高度
		 50		定时器(数值越小,滚动的速度越快 1000=1秒,建议不小于20)
		 5000		间歇停顿延迟时间(0为不停顿,1000=1秒)
		 3000		开始时的等待时间(0为不等待,1000=1秒)
		 (52)		间歇滚动间距(可选,该数值与延迟均为0则为鼠标悬停控制)
****/
function Marquee()
{
	this.ID = document.getElementById(arguments[0]);
	this.Direction = arguments[1];
	this.Step = this.BakStep = arguments[2];
	this.Width = arguments[3];
	this.HalfWidth = Math.round(arguments[3] / 2);
	this.Height = arguments[4];
	this.Timer = arguments[5];
	this.DelayTime = arguments[6];
	this.WaitTime = arguments[7];
	if(arguments[8] || arguments[8]==0)
		this.ScrollStep = arguments[8]
	else
		this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
	this.Correct = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
	this.ID.style.overflow = this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
	this.ID.noWrap = true;
	this.ID.style.width = this.Width;
	this.ID.style.height = this.Height;
	this.ClientScroll = this.Direction > 1 ? this.ID.scrollWidth : this.ID.scrollHeight;
	this.ID.innerHTML += this.ID.innerHTML;
	this.IsNotOpera = (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
	if(arguments.length >= 8)this.Start(this,this.Timer,this.DelayTime,this.WaitTime);
}

Marquee.prototype.Start = function(msobj,timer,delaytime,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.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);
							}
						}
			msobj.TimerID = setInterval(msobj.StartID,timer);
		}
	setTimeout(msobj.Begin,waittime);
}

Marquee.prototype.Scroll = function()
{
	if(this.Correct == 0 && this.CTL > this.ClientScroll)
	{
		this.ClientScroll = this.Direction > 1 ? Math.round(this.ID.scrollWidth / 2) : Math.round(this.ID.scrollHeight / 2);
		this.Correct = 1;
	}

	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;
	}
}



/* 光标跟随文字*/
var x,y;
var step=20;
var flag=0;
var message="";
var xpos=new Array();
var ypos=new Array();
function MoveTxt_Move(e)
{
	x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
	y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
	flag=1
}

function MoveTxt_Make() 
{
	if (flag==1 && document.all) 
	{
		for (i=message.length-1; i>=1; i--) 
		{
			xpos[i]=xpos[i-1]+step
			ypos[i]=ypos[i-1]       
		}
		xpos[0]=x+step
		ypos[0]=y
		for (i=0; i<message.length-1; i++) 
		{
			var thisspan = eval("MoveTxt_"+(i)+".style")
			thisspan.posLeft=xpos[i]
			thisspan.posTop=ypos[i]     
		}   
	}
	else if (flag==1 && document.layers) 
	{
		for (i=message.length-1; i>=1; i--) 
		{
			xpos[i]=xpos[i-1]+step
			ypos[i]=ypos[i-1]       
		}
		xpos[0]=x+step
		ypos[0]=y
		for (i=0; i<message.length-1; i++) 
		{
			var thisspan = eval("document.MoveTxt_"+i)
			thisspan.left=xpos[i]
			thisspan.top=ypos[i]
		}   
	}
	var timer=setTimeout("MoveTxt_Make()",30)
}

function MoveTxt(sText, sColor)
{
	if (sColor.length<6) sColor = "#ff8040";
	message = sText;
	message=message.split("");
	for (var i=0;i<=message.length-1;i++)
	{
		xpos[i]=-50
	}
	for (var i=0;i<=message.length-1;i++) 
	{
		ypos[i]=-50
	}
	for (var i=0;i<=message.length-1;i++) 
	{
		document.write("<span id='MoveTxt_"+i+"'class='movetxtstyle' style='COLOR: "+sColor+"; FONT-FAMILY: 宋体; FONT-SIZE: 9pt; FONT-WEIGHT: bold; POSITION: absolute; TOP: -50px; VISIBILITY: visible'>")
		document.write(message[i])
		document.write("</span>")
	}
	if (document.layers)
	{
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = MoveTxt_Move;
	MoveTxt_Make();
}


