var pn = 100;
function getID()
{
	pn=pn+1;
	return pn;
}
// 上下移动窗口
function scrollDiv(oObj, uObj, dObj)
{
	var self = this;
	this.init = function()
	{
		this.pos = 0;
		this.spd = 250;
		this.tim = null;		
		this.Obj = document.getElementById(oObj);
		this.Obj1 = document.getElementById(uObj);
		this.Obj2 = document.getElementById(dObj);
		if (this.Obj == null || this.Obj1 == null || this.Obj2 == null)
		{
			alert("初始化失败!");
			return null;
		}
		this.Obj.SourceObj = this.Obj1.SourceObj = this.Obj2.SourceObj= this;
		this.Obj1.onmouseover = new Function("this.SourceObj.Move(this.SourceObj, -1);");
		this.Obj1.onmouseout = new Function("this.SourceObj.Move(this.SourceObj, 0);");
		this.Obj2.onmouseover = new Function("this.SourceObj.Move(this.SourceObj, 1);");
		this.Obj2.onmouseout = new Function("this.SourceObj.Move(this.SourceObj, 0);");		
	}
	this.Move = function(obj, step)
	{		
		if (step == 0) { clearTimeout(obj.tim); }
		else if (step == 1)
		{
			obj.stp = 2;
			obj.tim = setTimeout(obj.Scroll, this.spd);	
		}
		else if (step == -1)
		{
			obj.stp = -2;
			obj.tim = setTimeout(obj.Scroll, this.spd);	
		}
	}
	this.Scroll = function()
	{
		var height = self.Obj.scrollHeight-self.Obj.offsetHeight;
		self.pos = self.pos + self.stp;
		if (self.pos<=0) self.pos = 0;
		if (self.pos>=height) self.pos = height;
		self.Obj.scrollTop = self.pos;
		//window.status = self.pos+"  "+self.Obj.scrollHeight+"  "+self.Obj.offsetHeight+"  "+height;
		self.tim = setTimeout(self.Scroll, this.spd);	
	}
	this.init();
}

// 移动图片
function MovePic(sFile, sUrl, sTitle, sType, sSpeed, sWidth, sHeight)
{
	var self = this;
	this.init = function ()
	{
		var sID = getID();
		var sFileType = sFile.toLowerCase().substring(sFile.length-3, sFile.length);
		var sHtml = "<div id='mObj"+sID+"' style='position:absolute;'>";
		if (sFileType =="jpg" || sFileType=="gif") { sHtml = sHtml +"<a href='"+sUrl+"' target='_blank' title='"+sTitle+"'><img src='"+sFile+"' border='0' alt='"+sTitle+"' width='"+ sWidth+"' height='"+sHeight+"'></a>"; }
		else if (sFileType =="swf") { sHtml = sHtml +"<embed src='"+sFile+"' quality=high type='application/x-shockwave-flash' width='"+sWidth+"' height='"+sHeight+"'></embed>"; }
		else if (sFileType =="png") { sHtml = sHtml +"<span style='width:"+sWidth+"px; height:"+ sHeight+"px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+ sFile+", sizingMethod=scale);'></span>"; }
		else { sHtml = sHtml +"<a href='"+sFile+"'>下载该文件</a>"; }	
		if (sUrl!="") {sHtml = sHtml +"</a>";}
		sHtml = sHtml +"</div>";
		document.write(sHtml);
		this.oObj = document.getElementById("mObj"+sID);
		this.oObj.visibility = "visible";
		this.movetype = sType;
		this.xPos = 20;
		this.yPos = document.body.clientHeight;
		this.step = 1;
		this.delay = 30;
		this.height = 0;
		this.Hoffset = 0;
		this.Woffset = 0;
		this.yon = 0;
		this.xon = 0;
		this.pause = true;		
		this.timer=setInterval(this.move, sSpeed);
	}

	this.move = function()
	{
		var width = document.body.clientWidth;
		var height = document.body.clientHeight;
		var Hoffset = self.oObj.offsetHeight;
		var Woffset = self.oObj.offsetWidth;
		if (self.movetype == "1")
		{
			self.oObj.style.pixelTop=document.body.scrollTop+100;
			self.oObj.style.pixelLeft=5;
		}
		else if (self.movetype == "2")
		{
			self.oObj.style.pixelTop=document.body.scrollTop+100;
			self.oObj.style.pixelLeft=width-Woffset-5;
		}
		else
		{
			self.oObj.style.left = self.xPos + document.body.scrollLeft;
			self.oObj.style.top = self.yPos + document.body.scrollTop;
			if (self.yon){	self.yPos = self.yPos + self.step; }
			else { self.yPos = self.yPos - self.step; }
			if (self.yPos < 0) { self.yon = 1; self.yPos = 0;}
			if (self.yPos >= (height - Hoffset)) 
			{
				self.yon = 0;
				self.yPos = (height - Hoffset);
			}
			if (self.xon) { self.xPos = self.xPos + self.step; }
			else { self.xPos = self.xPos - self.step; }
			if (self.xPos < 0) { self.xon = 1; self.xPos = 0; }
			if (self.xPos >= (width - Woffset)) { self.xon = 0; self.xPos = (width - Woffset); }
		}
	}
	this.init();
}

// 打开窗体
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;
}

// 多张图片轮流显示
function switchpic(sObj, sPic, sLink)
{
	this.init = function()
	{		
		oObj			= document.getElementById(sObj);
		this.Obj		= oObj;
		oObj.SourceObj 	= this;
		this.picArr	 	= sPic.split("|");
		this.urlArr		= sLink.split("|");
		this.picObj		= new Array();
		this.adNum		= 0;
		this.theTimer	= null;
		this.Obj.onclick = new Function("this.SourceObj.openUrl();");	
	
	}
	
	this.setTransition = function()
	{
		if (document.all)
		{
			this.Obj.filters.revealTrans.Transition=Math.floor(Math.random()*23); 
			this.Obj.filters.revealTrans.apply(); 
		}
	}
	
	this.playTransition = function()
	{
		if (document.all) this.Obj.filters.revealTrans.play() 
	}
	this.playAd = function(n)
	{
		clearInterval(this.theTimer);
		if (n<this.picArr.length)
		{
			this.setTransition(); 
			this.Obj.src=this.picArr[n]; 
			this.playTransition();
		}		
		this.theTimer=setInterval("oObj.SourceObj.nextAd(oObj.SourceObj)", 5000);
	}
	this.nextAd = function(cur)
	{
		if(cur.adNum<cur.picArr.length-1) { cur.adNum++;  }
		else { cur.adNum=0; }
		cur.playAd(cur.adNum);
	} 

	this.openUrl = function()
	{
		sUrl=this.urlArr[this.adNum]; 
		if (sUrl != "") { window.open(sUrl, "_blank"); }
	}
	this.init();
	this.nextAd(oObj.SourceObj);
}

function mTab(tArr, tMore, tIndex)
{
	this.curHead = null;
	this.curBody = null;
	this.curMore = null;
	this.curData = tArr;
	this.MoreObj = document.getElementById(tMore);
	if (tIndex == "" || tIndex == null) tIndex = 0;
	this.curIndex= tIndex;
	
	this.init = function()
	{
		for (var i=0; i<this.curData.length; i++)
		{
			var dHead = document.getElementById(this.curData[i][0]);
			var dBody = document.getElementById(this.curData[i][1]);
			if (dHead && dBody)
			{
				dHead.SourceObj = dBody.SourceObj = this;
				dHead.onmouseover = new Function("this.SourceObj.SelectTab(" + i + ")");
				if (i == tIndex)
				{
					dHead.className = "mtab_open";
					dBody.style.display = "";
					this.curHead = dHead;
					this.curBody = dBody;
					dHead.click();
				}
				else
				{
					dHead.className = "mtab_close";
					dBody.style.display == "none";
				}
			}
		}
	}
	this.SelectTab = function(curIndex)
	{
		this.curHead.className = "mtab_close";
		this.curBody.style.display = "none";
		this.curMore
		var dHead = document.getElementById(this.curData[curIndex][0]);
		var dBody = document.getElementById(this.curData[curIndex][1]);
		var dMore = this.curData[curIndex][2];
		if (this.MoreObj != null) this.MoreObj.href=dMore;   
		dHead.className = "mtab_open";
		dBody.style.display = "";
		this.curHead = dHead;
		this.curBody = dBody;
	}	
	this.init();
}

// 切换动态
function switchnew(name, total, class1, class2, isauto, speed)
{
	var self = this;
	this.init = function()
	{
		if (isauto == null) isauto = false;
		if (speed == null) speed = 6000;
		this.name = name;
		this.total = total;
		this.isauto = isauto;
		this.speed = speed;
		this.classname1 = class1;
		this.classname2 = class2;
		this.cur = 1;
		this.disp();
	}
	this.open = function(n) { this.curid = n; this.disp(); }
	this.auto = function()
	{
		if (this.curid>this.total) this.curid = 1;	
		this.disp();
		this.curid++;				
	}
	this.disp = function()
	{
		for(var t=1; t<=self.total; t++)
		{
			var tPic = document.getElementById(self.name+"p"+t);
			var tList = document.getElementById(self.name+"n"+t);
			if (tPic != null && tList != null)
			{
				if (t == this.curid) { tPic.classname=self.class1; tList.style.display = ''; }	
				else { tPic.classname=self.class2; tList.style.display = 'none'; }
			}
		}			
	}
	if (this.isauto) { this.timer=setTimeout(self.disp, this.speed); }
	this.init();
	return this;
}


/* 滚动 样式类
		容器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;
	}
}

// 多张图片滚动
function RollingPic(sObj, sObj1, sObj2, sSpeed, sDirection)
{
	var self = this;	
	this.init = function()
	{
		this.speed = sSpeed;
		this.Obj	= document.getElementById(sObj);
		this.Obj1	= document.getElementById(sObj1);
		this.Obj2	= document.getElementById(sObj2);
		this.Obj2.innerHTML = this.Obj1.innerHTML;
		this.timer=setInterval(this.move, this.speed);		
		this.Obj.onmouseover=function() {clearInterval(self.timer)};
		this.Obj.onmouseout=function() {self.timer=setInterval(self.move, self.speed)};
	}
	
	this.move = function()
	{
		if (sDirection == 1) //向上
		{
			if(self.Obj2.offsetTop-self.Obj.scrollTop<=0) { self.Obj.scrollTop-=self.Obj1.offsetHeight; }
			else{self.Obj.scrollTop++; }
		}
		else if (sDirection == 2) // 向下
		{
			if(self.Obj1.offsetTop-self.Obj.scrollTop>=0) { self.Obj.scrollTop+=self.Obj2.offsetHeight; }
			else{self.Obj.scrollTop--; }

		}
		else if (sDirection == 3) // 向左
		{
			if(self.Obj2.offsetWidth-self.Obj.scrollLeft<=0) { self.Obj.scrollLeft-=self.Obj1.offsetWidth; }
			else{self.Obj.scrollLeft++;}
		}
		else if (sDirection == 4) // 向右
		{
			if(self.Obj.scrollLeft<=0) { self.Obj.scrollLeft+=self.Obj2.offsetWidth; }
			else{ self.Obj.scrollLeft--; }
		}
	}
	this.init();
}

/* 光标跟随文字*/
function MouseTxt(sText, sColor)
{
	var self = this;
	this.init = function()
	{
		this.name = "mousetext";
		this.xpos = new Array();
		this.ypos = new Array();
		this.x = 0;
		this.y = 0;
		this.timer = 0;
		this.step=20;
		this.flag=0;		
		if (sColor.length<6) sColor = "#ff8040";
		this.message = sText.split("");	
		for (var i=0;i<this.message.length;i++){ this.xpos[i]=-50 }
		for (var i=0;i<this.message.length;i++){ this.ypos[i]=-50 }
		for (var i=0;i<this.message.length;i++) 
		{
			document.write("<span id='"+this.name+"_"+i+"'class='movetxtstyle' style='COLOR: "+sColor+"; FONT-FAMILY: 宋体; FONT-SIZE: 9pt; FONT-WEIGHT: bold; POSITION: absolute; TOP: -50px; VISIBILITY: visible'>")
			document.write(this.message[i])
			document.write("</span>")
		}
		if (document.layers) {	document.captureEvents(Event.MOUSEMOVE); }
		document.onmousemove = this.move;
		this.make();
	}
	
	this.move = function(e)
	{
		self.x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX;
		self.y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY;
		self.flag=1;
	}

	this.make = function()
	{
		if (self.flag==1 && document.all) 
		{
			for (var i=self.message.length; i>=1; i--) 
			{
				self.xpos[i]=self.xpos[i-1]+self.step;
				self.ypos[i]=self.ypos[i-1];
			}
			self.xpos[0]=self.x+self.step
			self.ypos[0]=self.y
			for (var i=0; i<self.message.length; i++) 
			{
				var thisspan = eval(""+self.name+"_"+(i)+".style")
				thisspan.posLeft=self.xpos[i];
				thisspan.posTop=self.ypos[i];
			}   
		}
		else if (self.flag==1 && document.layers) 
		{
			for (var i=self.message.length; i>=1; i--) 
			{
				self.xpos[i]=self.xpos[i-1]+self.step;
				self.ypos[i]=self.ypos[i-1];
			}
			self.xpos[0]=self.x+self.step;
			self.ypos[0]=self.y;
			for (i=0; i<self.message.length; i++) 
			{
				var thisspan = eval("document."+self.name+"_"+i)
				thisspan.left=self.xpos[i]
				thisspan.top=self.ypos[i]
			}   
		}
		self.timer=setTimeout(self.make, 30)
	}
	this.init();
}

// 自动显示时间
function disptime(sID)
{
	var self = this;
	this.init = function()
	{
		this.oObj = document.getElementById(sID);
	}
	this.disp = function()
	{
		var thistime= new Date();
		var hours=thistime.getHours();
		var minutes=thistime.getMinutes();
		var seconds=thistime.getSeconds();
		if (eval(hours) <10) {hours="0"+hours; }
		if (eval(minutes) < 10) {minutes="0"+minutes; }
		if (eval(seconds) < 10) {seconds="0"+seconds; }
		self.oObj.innerHTML = hours+":"+minutes+":"+seconds;		
	}
	this.timer=setTimeout(this.disp, 1000)
	this.init();
}

// 添加文字复制信息

var copyText = "";
function copyAddText()
{ 
	event.returnValue=false; 
	var txt_cr=document.selection.createRange().text; 
	var copy_cr="本文来自："+document.URL+"， "+copyText;
	clipboardData.setData("Text","\r\n"+txt_cr+"\r\n"+copy_cr+"\r\n"); 
} 

