
//浮动层对象 接口对象:function JSFX_FloatTopDivs(time--刷新时间);用法:新建一个浮动层对象,
//调用addLayer('浮动层ID',方式(从下向上或从上向下,Enter "frombottom" or "fromtop"),起始X,起始Y)即可
function JSFX_FloatTopDiv(_layer,verticalpos,startX,startY,z_index)
{
	this.verticalpos=verticalpos;//Enter "frombottom" or "fromtop"
	this.startX =startX;this.startY = startY;this.d = document;this.ftlOb='';
	this.z_index=z_index;
	this.getScrollTop=function () 
	{ 
		var scrollTop; 
		if (document.documentElement&&document.documentElement.scrollTop){ scrollTop = document.documentElement.scrollTop;}
		else if(document.body){scrollTop=document.body.scrollTop;}
		else if(window.pageYOffset){scrollTop=window.pageYOffset;} 
		return scrollTop; 
	} ;
	this.getClientHeight=function () 
	{ 
		var clientHeight; 
		if (document.documentElement&&document.documentElement.clientHeight){clientHeight=document.documentElement.clientHeight;}
		else if(document.body){clientHeight = document.body.clientHeight;}
		else if(window.innerHeight){clientHeight = window.innerHeight;} 
		return clientHeight; 
	} ;
	this.ml=function (id)
	{
		var el=this.d.getElementById?this.d.getElementById(id):this.d.all?d.all[id]:this.d.layers[id];
		el.style.position="absolute";
		if(this.d.layers)el.style.zIndex=1;
		if(this.z_index);
		el.x = this.startX;
		if (this.verticalpos=="fromtop")el.y = this.startY;
		else{el.y = this.getScrollTop()+this.getClientHeight();el.y -= this.startY;}
		return el;
	};
	this.stayTopLeft=function ()
	{
		if (this.verticalpos=="fromtop"){var pY = this.getScrollTop();this.ftlObj.y += (pY + this.startY - this.ftlObj.y)/8;}
		else{var pY = this.getScrollTop()+this.getClientHeight();this.ftlObj.y += (pY - this.startY - this.ftlObj.y)/8;}
		this.ftlObj.style.left=this.ftlObj.x+'px';
		this.ftlObj.style.top=this.ftlObj.y+'px' ;
	};
	this.ftlObj = this.ml(_layer);
} 

var __sto = setTimeout;
window.setTimeout = function(callback,outtime,param){var _cb = function(){callback(param,outtime);};__sto(_cb,outtime);};

function JSFX_FloatTopDivs(outtime)
{
	this.outtime=outtime;this._layers=new Array();
	this.addLayer=function (_layer,verticalpos,startX,startY,z_index)
	{
		if(document.getElementById?document.getElementById(_layer):document.all?d.all[_layer]:document.layers[_layer])
			this._layers[this._layers.length]=new JSFX_FloatTopDiv(_layer,verticalpos,startX,startY,z_index);
	};
	 window.stayTopLeft=function(_layers,outtime)
	{
		if(_layers.length>0){for(var i=0;i<_layers.length;i++) _layers[i].stayTopLeft();}
		window.setTimeout(stayTopLeft,outtime,_layers);
	};
	stayTopLeft(this._layers,this.outtime);
}