﻿// JScript 文件

function MsnMessage()
{
	var LayerId = null;       //层ID
	var LayerZIndex = null;   //层的绝对定位(第几层)
	var LayerHeight = null;   //层高度
	var LayerWidth = null;    //层宽度
	var LayerBgColor = null;  //层背景色
	var LayerHTML = null;     //层内HTML
	//var Layerright = null;  
    //var Layerbottom = null;
    //var Layerleft   = null;
    //var Layertop    = null;
	var pic_div = null;
	this.setLayerId = function(lay_LayerId){LayerId=lay_LayerId;}
	this.setLayerZIndex = function(lay_LayerZIndex){LayerZIndex = lay_LayerZIndex;}
	this.setLayerHeight = function(lay_LayerHeight)
	{
		LayerHeight=lay_LayerHeight;
		//Layerbottom = screen.height; 
		//Layertop = Layerbottom - LayerHeight;
	}
	this.setLayerWidth = function(lay_LayerWidth)
	{
		LayerWidth=lay_LayerWidth;
		//Layerright    = screen.width -1; 
		//Layerleft    = Layerright - LayerWidth; 
	}
	this.setLayerBgColor = function(lay_LayerBgColor){LayerBgColor = lay_LayerBgColor;}
	this.setLayerHTML = function(lay_LayerHTML){LayerHTML = lay_LayerHTML;}
	this.setDrawDiv = function()
	{
		pic_div = "<DIV id='" + LayerId + "' style='BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid;LEFT: 0px; VISIBILITY: hidden; BORDER-LEFT: #a6b4cf 1px solid;BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px;Z-INDEX:" + LayerZIndex + ";HEIGHT:" + LayerHeight + ";WIDTH:" + LayerWidth + ";BACKGROUND-COLOR:" + LayerBgColor + ";'>" + LayerHTML + "</DIV>";
		document.write(pic_div);
	}
	this.setStart = function()
	{
		getMsg();
	}
	
    //this.setRect = function(left,right,top,bottom)
	//{
	//	Layerleft        = left    !=null?left:Layerright-LayerWidth; 
    //    Layerright        = right    !=null?right:Layerleft +LayerWidth; 
    //    Layerbottom        = bottom!=null?(bottom>screen.height?screen.height:bottom):screen.height; 
    //    Layertop        = top    !=null?top:Layerbottom - LayerHeight; 
	//} 

	//开始提示
	var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
	function getMsg()
	{
		try{
		divTop = parseInt(document.getElementById(LayerId).style.top,10)
		divLeft = parseInt(document.getElementById(LayerId).style.left,10)
		divHeight = parseInt(document.getElementById(LayerId).offsetHeight,10)
		divWidth = parseInt(document.getElementById(LayerId).offsetWidth,10)
		docWidth = document.body.clientWidth;
		docHeight = document.body.clientHeight;
		document.getElementById(LayerId).style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;//  divHeight
		document.getElementById(LayerId).style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth
		document.getElementById(LayerId).style.visibility="visible"
		objTimer = window.setInterval(moveDiv,10)
		}
		catch(e){}
	}

	function resizeDiv()
	{
		i+=1
		if(i>500) closeDiv()
		try{
		divHeight = parseInt(document.getElementById(LayerId).offsetHeight,10)
		divWidth = parseInt(document.getElementById(LayerId).offsetWidth,10)
		docWidth = document.body.clientWidth;
		docHeight = document.body.clientHeight;
		document.getElementById(LayerId).style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10)
		document.getElementById(LayerId).style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)
		}
		catch(e){}
	}

	function moveDiv()
	{
		try
		{
		if(parseInt(document.getElementById(LayerId).style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
		{
		window.clearInterval(objTimer)
		objTimer = window.setInterval(resizeDiv,1)
		}
		divTop = parseInt(document.getElementById(LayerId).style.top,10)
		document.getElementById(LayerId).style.top = divTop - 1
		}
		catch(e){}
	}
	function closeDiv()
	{
		document.getElementById(LayerId).style.visibility='hidden';
		if(objTimer) window.clearInterval(objTimer)
	}

	//关闭层
	this.setClose = function ()
	{
		closeDiv();
	}
}

//浮动
function Fudong()
{
	var RelativePosition = null;  //图层相对位置
	var LayerId = null;       //层ID
	var LayerZIndex = null;   //层的绝对定位(第几层)
	var LayerHeight = null;   //层高度
	var LayerWidth = null;    //层宽度
	var LayerBgColor = null;  //层背景色
	var LayerXDistance = null; //对应浏览器横向的距离
	var LayerYDistance = null; //对应浏览器纵向的距离
	var LayerHTML = null;      //层内HTML
	var LayerShowFlag = null;  //初始化层是否可见,true为可见,false为不可见
	var LayerScollFlag = null;
	var pic_div = null;
	var obj = null;
	var oTop = null;
	this.setRelativePosition = function(lay_RelativePosition){RelativePosition=lay_RelativePosition;}
	this.setLayerId = function(lay_LayerId){LayerId=lay_LayerId;}
	this.setLayerZIndex = function(lay_LayerZIndex){LayerZIndex = lay_LayerZIndex;}
	this.setLayerHeight = function(lay_LayerHeight){LayerHeight=lay_LayerHeight;}
	this.setLayerWidth = function(lay_LayerWidth){LayerWidth=lay_LayerWidth;}
	this.SetLayerBgColor = function(lay_LayerBgColor){LayerBgColor = lay_LayerBgColor;}
	this.setLayerXDistance = function(lay_LayerXDistance)
	{
		LayerXDistance = lay_LayerXDistance;
		if(RelativePosition == "左上")
		{
			LayerXDistance = "left:" + LayerXDistance + ";";
		}
		if(RelativePosition == "右上")
		{
			LayerXDistance = "right:" + LayerXDistance + ";";
		}
		if(RelativePosition == "左下")
		{
			LayerXDistance = "left:" + LayerXDistance + ";";
		}
		if(RelativePosition == "右下")
		{
			LayerXDistance = "right:" + LayerXDistance + ";";
		}
	}
	this.setLayerYDistance = function(lay_LayerYDistance)
	{
		LayerYDistance = lay_LayerYDistance;
		if(RelativePosition == "左上")
		{
			LayerYDistance = "top:" + LayerYDistance + ";";
		}
		if(RelativePosition == "右上")
		{
			LayerYDistance = "top:" + LayerYDistance + ";";
		}
		if(RelativePosition == "左下")
		{
			LayerYDistance = "bottom:" + LayerYDistance + ";";
		}
		if(RelativePosition == "右下")
		{
			LayerYDistance = "bottom:" + LayerYDistance + ";";
		}
	}
	this.setLayerHTML = function(lay_LayerHTML){LayerHTML = lay_LayerHTML;}
	this.setLayerShowFlag = function(lay_LayerShowFlag)
	{
		LayerShowFlag = lay_LayerShowFlag;
		if(!LayerShowFlag)
		{
			LayerShowFlag = "display:none;";
		}
		pic_div = "<div id='" + LayerId + "' style='background-color:" + LayerBgColor + ";position:absolute;z-index:" + LayerZIndex + ";height:" + LayerHeight + ";width:" + LayerWidth + ";" + LayerXDistance + LayerYDistance + LayerShowFlag + "'>" + LayerHTML + "</div>";
		document.write(pic_div);
		obj = document.getElementById(LayerId);
		oTop = obj.offsetTop;
	}
	this.setLayerScollFlag = function(lay_LayerScollFlag)
	{
		LayerScollFlag = lay_LayerScollFlag;
	}
	this.setStart = function()
	{
		if(LayerScollFlag)
		{
			setInterval(f2, 1);
		}
	}
	function f2()
	{
		var oldTop,newTop,topC;
		oldTop = parseInt(obj.style.top,10);
		newTop = document.body.scrollTop + oTop;
		topC = Math.ceil(Math.abs(newTop-oldTop)/20);
		if(newTop != oldTop)
		{
			obj.style.top = oldTop + topC * (newTop>oldTop?1:-1);
		}
	}

	
}

//飘浮
function PiaoFu()
{
	var layid = null;        //层ID
	var layindex = null;     //层的绝对定位(第几层)
	var layheight = null;    //层高度
	var laywidth = null;     //层宽度
	var layhtml = null;      //层内HTML
	var LayerBgColor = null;  //层背景色
	var flag = null;         //初始化层是否可见,true为可见,false为不可见
	var x = 50;
	var y = 60;
	var xin = true;
	var yin = true;
	var step = 1;
	var obj = null;
    var showflag = "";
	var delay = 80;
	var pic_div = null;
	this.setlayid = function(lay_layid)
	{
		layid=lay_layid;
	}
	this.setlayindex = function(lay_layindex){layindex=lay_layindex;}
	this.setlayheight = function(lay_layheight){layheight = lay_layheight;}
	this.setlaywidth = function(lay_laywidth){laywidth = lay_laywidth;}
	this.setlayhtml = function(lay_layhtml){layhtml= lay_layhtml;}
	this.SetLayerBgColor = function(lay_LayerBgColor){LayerBgColor = lay_LayerBgColor;}
	this.setflag = function(lay_flag)
	{
		flag = lay_flag;
		if(!flag)
		{
			showflag = "display:none;";
		}
		pic_div = "<div id='" + layid + "' style='position:absolute;background-color:" + LayerBgColor +  ";z-index:" + layindex  + ";height:" + layheight + ";width:" + laywidth + ";" + showflag + "'>" + layhtml + "</div>";
		document.write(pic_div);
		obj = document.getElementById(layid);
	}
	this.setStart = function()
	{
		var itl= setInterval(floatAD,delay);
		obj.onmouseover=function(){clearInterval(itl)}
		obj.onmouseout=function(){itl=setInterval(floatAD, delay)}
	}

	function floatAD() 
	{
		var L=0;
		var T=0;
		var R= document.body.clientWidth-obj.offsetWidth;
		var B = document.body.clientHeight-obj.offsetHeight;
		obj.style.left = x + document.body.scrollLeft;
		obj.style.top = y + document.body.scrollTop;
		x = x + step*(xin?1:-1) 
		if (x < L) { xin = true; x = L} 
		if (x > R){ xin = false; x = R} 
		y = y + step*(yin?1:-1) 
		if (y < T) { yin = true; y = T } 
		if (y > B) { yin = false; y = B } 
	}
}
   
function OpenMessage()
{
	var RelativePosition = null;  //图层相对位置
	var LayerId = null;       //层ID
	var LayerZIndex = null;   //层的绝对定位(第几层)
	var LayerHeight = null;   //层高度
	var LayerWidth = null;    //层宽度
	var LayerBgColor = null;  //层背景色
	var LayerXDistance = null; //对应浏览器横向的距离
	var LayerYDistance = null; //对应浏览器纵向的距离
	var LayerHTML = null;      //层内HTML
	var LayerShowFlag = null;  //初始化层是否可见,true为可见,false为不可见
	var LayerIsShowOneCountFlag = null;  //是否只显示一次; true为只显示一次;false为显示多次;
	var pic_div = null;
	var obj = null;
	var count = 0;
	this.setRelativePosition = function(lay_RelativePosition){RelativePosition=lay_RelativePosition;}
	this.setLayerId = function(lay_LayerId){LayerId=lay_LayerId;}
	this.setLayerZIndex = function(lay_LayerZIndex){LayerZIndex = lay_LayerZIndex;}
	this.setLayerHeight = function(lay_LayerHeight){LayerHeight=lay_LayerHeight;}
	this.setLayerWidth = function(lay_LayerWidth){LayerWidth=lay_LayerWidth;}
	this.SetLayerBgColor = function(lay_LayerBgColor){LayerBgColor = lay_LayerBgColor;}
	this.setLayerXDistance = function(lay_LayerXDistance)
	{
		LayerXDistance = lay_LayerXDistance;
		if(RelativePosition == "左上")
		{
			LayerXDistance = "left:" + LayerXDistance + ";";
		}
		if(RelativePosition == "右上")
		{
			LayerXDistance = "right:" + LayerXDistance + ";";
		}
		if(RelativePosition == "左下")
		{
			LayerXDistance = "left:" + LayerXDistance + ";";
		}
		if(RelativePosition == "右下")
		{
			LayerXDistance = "right:" + LayerXDistance + ";";
		}
	}
	this.setLayerYDistance = function(lay_LayerYDistance)
	{
		LayerYDistance = lay_LayerYDistance;
		if(RelativePosition == "左上")
		{
			LayerYDistance = "top:" + LayerYDistance + ";";
		}
		if(RelativePosition == "右上")
		{
			LayerYDistance = "top:" + LayerYDistance + ";";
		}
		if(RelativePosition == "左下")
		{
			LayerYDistance = "bottom:" + LayerYDistance + ";";
		}
		if(RelativePosition == "右下")
		{
			LayerYDistance = "bottom:" + LayerYDistance + ";";
		}
	}
	this.setLayerHTML = function(lay_LayerHTML){LayerHTML = lay_LayerHTML;}
	this.setLayerShowFlag = function(lay_LayerShowFlag)
	{
		LayerShowFlag = lay_LayerShowFlag;
		if(!LayerShowFlag)
		{
			LayerShowFlag = "display:none;";
		}
		pic_div = "<div id='" + LayerId + "' style='background-color:" + LayerBgColor + ";position:absolute;z-index:" + LayerZIndex + ";height:" + LayerHeight + ";width:" + LayerWidth + ";" + LayerXDistance + LayerYDistance + LayerShowFlag + "'>" + LayerHTML + "</div>";
		document.write(pic_div);
		obj = document.getElementById(LayerId);
	}
	this.setLayerIsShowOneCountFlag = function(lay_LayerIsShowOneCountFlag){LayerIsShowOneCountFlag = lay_LayerIsShowOneCountFlag;}
	this.setStart = function()
	{
		if(LayerIsShowOneCountFlag)
		{
			setTimeout(showdiv,2000);
		}
		else
		{
			setTimeout(displaydiv,2000);
		}
	}

	function showdiv()
	{
		if(document.getElementById(LayerId).style.display == "none")
		{
			document.getElementById(LayerId).style.display = "";
			setTimeout(noshowdiv,2000);
		}
		if(document.getElementById(LayerId).style.display == "")
		{
			setTimeout(noshowdiv,2000);
		}
	}
	function noshowdiv()
	{
		if(document.getElementById(LayerId).style.display == "")
		{
			document.getElementById(LayerId).style.display = "none";
		}
	}

	function displaydiv()
	{
		if(document.getElementById(LayerId).style.display == "none")
		{
			if(count < 3)
			{
				document.getElementById(LayerId).style.display = "";
				setTimeout(nodisplaydiv,2000);
			}
		}
		if(document.getElementById(LayerId).style.display == "")
		{
			document.getElementById(LayerId).style.display = "none";
			count = count + 1;
			setTimeout(nodisplaydiv,2000);
		}
	}

	function nodisplaydiv()
	{
		if(document.getElementById(LayerId).style.display == "")
		{
			document.getElementById(LayerId).style.display = "none";
			count = count + 1;
			setTimeout(displaydiv,2000);
			
		}
		if(document.getElementById(LayerId).style.display == "none")
		{
			if(count < 3)
			{
				document.getElementById(LayerId).style.display = "";
				setTimeout(displaydiv,2000);
			}
		}
	}
}
     
//关闭层     
function DivClose(a)
{
	document.getElementById(a).style.display="none";
}

/********************************/
/*	文字或图片自动循环滚动		*/
/*		IE6 FF1.0.4				*/
/*		不支持xhtml声明的文档	*/
/*		2006-12-17 v1.0			*/
/********************************/

//*********不要修改这部分***************
//scrollBodyId:	String 内部滚动div的id
//scrollBoxId:	String 外面限制div的id
//showHeight:	Int 限制显示高度
//showWidth:	Int 限制显示宽度
//lineHeight:	Int 每行的高度
//stopTime:		Int 间隔停止的时间（毫秒）
//speed:		Int 滚动速度（毫秒，越小越快）
//objhtml:      String 层内TML
//hiddenBodyId: String 隐藏div的id
//scrollFlag:   Bool 是否滚动的标志(true表示不动滚动,false表示滚动)
var ScrollObj = function(scrollBodyId,scrollBoxId,showHeight,showWidth,lineHeight,stopTime,speed,objhtml,hiddenBodyId,scrollFlag) {
	this.obj = document.getElementById(scrollBodyId);
	this.box = document.getElementById(scrollBoxId);
	this.hiddenobj = document.getElementById(hiddenBodyId);

	this.obj.innerHTML = objhtml;
	this.hiddenobj.innerHTML += this.obj.innerHTML;  
	this.obj.innerHTML += this.obj.innerHTML;
	
	with(this.obj){
	  style.width=showWidth;
	  style.height=showHeight;
	  style.overflowX="visible";
	  style.overflowY="hidden";
	  style.position = "relative";
	  noWrap=true;
	}
	
	this.scrollUp = doScrollUp;

	//this.stopScroll = false;
	this.stopScroll = scrollFlag;
	this.curLineHeight = 0;
	this.lineHeight = lineHeight;
	this.curStopTime = 0;
	this.preTopa = 0;
	this.stopTime = stopTime;
	this.speed = speed;
	this.obj.scrollTop=0;

	this.object = scrollBodyId + "Object";
	eval(this.object + "=this");
	setInterval(this.object+".scrollUp()",speed);
	//this.obj.onmouseover=new Function(this.object+".stopScroll=true");
	//this.obj.onmouseout=new Function(this.object+".stopScroll=false");
}
function doScrollUp() {
	if( this.stopScroll == true )
		return;
  	this.curLineHeight += 1;
  	if( this.curLineHeight == this.lineHeight ) {
  		this.curStopTime += 1;
		this.curLineHeight -= 1;
  		if( this.curStopTime == this.stopTime ) {
  			this.curLineHeight = 0;
  			this.curStopTime = 0;
  		}
  	}
	else {  
		 this.preTopa = this.obj.scrollTop;
	  	 this.obj.scrollTop += 1;
	  	 if(this.preTopa==this.obj.scrollTop){
		 this.obj.scrollTop=this.hiddenobj.offsetHeight-this.lineHeight;
		 this.obj.scrollTop+=1;
	   }
  	}
}
//***************这以上不要修改******************



