/////////////////////////////////////////////////////////////////////

	var inFloatLayers       = new Array();
	var inFloatLayersByName = new Array();

	function addinFloatLayer(n,offX,offY,trg,spd){new inFloatLayer(n,offX,offY,trg,spd);}
	function getinFloatLayer(n){return inFloatLayersByName[n];}
	function aligninFloatLayers(){for(var i=0;i<inFloatLayers.length;i++)inFloatLayers[i].align();}

	function getinXCoord(el,trg) {
		x=0;
		while(el && el!=trg){
			x+=el.offsetLeft;
			el=el.offsetParent;
		}
		return x;
	}
	function getinYCoord(el,trg) {
		y=0;
		while(el && el!=trg){
			y+=el.offsetTop;
			el=el.offsetParent;
		}
		return y;
	}

	/////////////////////////////////////////////////////////////////////

	inFloatLayer.prototype.setFloatToTop=setinTopFloater;
	//inFloatLayer.prototype.setFloatToBottom=setinBottomFloater;
	inFloatLayer.prototype.setFloatToLeft=setinLeftFloater;
	//inFloatLayer.prototype.setFloatToRight=setinRightFloater;
	inFloatLayer.prototype.initialize=defineinFloater;
	inFloatLayer.prototype.adjust=adjustinFloater;
	inFloatLayer.prototype.align=aligninFloater;

	function inFloatLayer(n, offX, offY, trg, spd) {
		this.index=inFloatLayers.length;

		inFloatLayers.push(this);
		inFloatLayersByName[n] = this;

		this.name    = n;
		this.floatX  = 0;
		this.floatY  = 0;
		this.prt	 = trg;
		this.tm      = null;
		this.steps   = spd;
		this.alignHorizontal=leftinFloater
		this.alignVertical=topinFloater
		this.ifloatX = Math.abs(offX)+getXCoord(document.getElementById(this.prt));
		this.ifloatY = Math.abs(offY)+getYCoord(document.getElementById(this.prt));
		
	}

	/////////////////////////////////////////////////////////////////////

	function defineinFloater(){
		this.layer  = document.getElementById(this.name);
		this.width  = this.layer.offsetWidth;
		this.height = this.layer.offsetHeight;
		this.prevX  = this.layer.offsetLeft;
		this.prevY  = this.layer.offsetTop;
		
		//alert (this.prevY);
	}

	function adjustinFloater() {
		this.tm=null;
		
		//alert(this.name);
		//if(this.layer.style.position!='absolute')return;

		var dx = Math.abs(this.floatX-this.prevX);
		var dy = Math.abs(this.floatY-this.prevY);
		
		//document.getElementById('floatCoord').innerHTML='prevX: '+this.prevX+'<br />prevY: '+this.prevY;
		
		//getXCoord(document.getElementById(this.prt))
		
		if (dx < this.steps/2)
			cx = (dx>=1) ? 1 : 0;
		else
			cx = Math.round(dx/this.steps);

		if (dy < this.steps/2)
			cy = (dy>=1) ? 1 : 0;
		else
			cy = Math.round(dy/this.steps);

		if (this.floatX > this.prevX)
			this.prevX += cx;
		else if (this.floatX < this.prevX)
			this.prevX -= cx;

		if (this.floatY > this.prevY)
			this.prevY += cy;
		else if (this.floatY < this.prevY)
			this.prevY -= cy;

		this.layer.style.left = this.prevX+"px";
		this.layer.style.top  = this.prevY+"px";

		if (cx!=0||cy!=0){
			if(this.tm==null)this.tm=setTimeout('inFloatLayers['+this.index+'].adjust()',50);
		}else
			aligninFloatLayers();
	}

	function setinLeftFloater(){this.alignHorizontal=leftinFloater;}
	//function setinRightFloater(){this.alignHorizontal=rightinFloater;}
	function setinTopFloater(){this.alignVertical=topinFloater;}
	//function setinBottomFloater(){this.alignVertical=bottominFloater;}

	function leftinFloater(){
	
		var iepos=0;
	
		 if (jQuery.browser.msie) {
			if (jQuery.browser.version.substr(0,2)=='6.'){ //|| jQuery.browser.version.substr(0,2)=='7.'){
				ref=document.getElementById('page');
				//var iepos=ref.offsetLeft;
				//var iepos=0;
				//alert (iepos);
				//this.ifloatY -=ref.offsetTop;

			}
		 }
	
		this.floatX=Math.max(getXCoord(document.getElementById(this.prt))+this.ifloatX-iepos,Math.max(document.documentElement.scrollLeft,document.body.scrollLeft)+this.ifloatX+10-iepos);
	}
	
	function topinFloater(){
	
		var iepos=0;
	
		 if (jQuery.browser.msie) {
			if (jQuery.browser.version.substr(0,2)=='6.' || jQuery.browser.version.substr(0,2)=='7.'){
				ref=document.getElementById('page');
				var iepos=ref.offsetTop;
				
				//this.ifloatY -=ref.offsetTop;
			}
		 }
	
		this.floatY=Math.max(getYCoord(document.getElementById(this.prt))+this.ifloatY-iepos,Math.max(document.documentElement.scrollTop,document.body.scrollTop)+this.ifloatY+70-iepos);
	}
	
	//function topinFloater(){this.floatY = Math.max(document.documentElement.scrollTop,document.body.scrollTop) + this.ifloatY + getYCoord(document.getElementById(this.prt)) }
	/*function rightinFloater(){this.floatX = Math.max(document.documentElement.scrollLeft,document.body.scrollLeft) + Math.max(document.documentElement.clientWidth,document.body.clientWidth) - this.ifloatX - this.width;}
	function bottominFloater(){this.floatY = Math.max(document.documentElement.scrollTop,document.body.scrollTop) + Math.max(document.documentElement.clientHeight,document.body.clientHeight) - this.ifloatY - this.height;}*/
	
	/*function leftFloater(){this.floatX = document.body.scrollLeft + this.ifloatX;}
	function topFloater(){this.floatY = document.body.scrollTop + this.ifloatY; alert(document.body.scrollTop)}
	function rightFloater(){this.floatX = document.body.scrollLeft + document.body.clientWidth - this.ifloatX - this.width;}
	function bottomFloater(){this.floatY = document.body.scrollTop + document.body.clientHeight - this.ifloatY - this.height;}*/

	function aligninFloater(){
		if(this.layer==null)this.initialize();
		this.alignHorizontal();
		this.alignVertical();
		if(this.prevX!=this.floatX || this.prevY!=this.floatY){
			if(this.tm==null)this.tm=setTimeout('inFloatLayers['+this.index+'].adjust()',50);
		}
	}
