/*******************************************************************
*
* File    : JSFX_FloatingLayer.js © JavaScript-FX.com
*
* Created : 2001/03/16
*
* Author  : Roy Whittle www.Roy.Whittle.com
*           
* Purpose : To make and positional div float to
*		one plave on the page and stay there.
*
* History
* Date         Version        Description
*
* 2001-03-17	2.0		Converted for javascript-fx
***********************************************************************/
JSFX.FloatingLayer = function(theDiv, x, y)
{
	//Call the superclass constructor
	this.superC = JSFX.Layer;
	this.superC(JSFX.findLayer(theDiv), x, y);

	this.baseX = x;
	this.baseY = y;
	this.x = x;
	this.y = y;
	this.moveTo(x,y);
	this.show();

}
JSFX.FloatingLayer.prototype = new JSFX.Layer;

JSFX.FloatingLayer.prototype.animate = function()
{
	var targetX;
	var targetY;
	if(this.baseX > 0)
		targetX = JSFX.Browser.getMinX() + this.baseX;
	else
		targetX = JSFX.Browser.getMaxX() + this.baseX;

	//alert("before if: " + this.baseY);
	if(this.baseY > 0)
	{
		//alert("in if: " + this.baseY);
		targetY = JSFX.Browser.getMinY() + this.baseY;
	}
	else
	{
		//alert("in else: " + this.baseY);
		targetY = JSFX.Browser.getMaxY() + this.baseY;
	}

	var dx = (targetX - this.x)/8;
	//we need to decrease by the height of the container (521px) so the name and links on the sample preview image get displayed;
	//20 is the number of steps, the greater the number the smoother the easing of the movement is
	if (navigator.userAgent.indexOf("Firefox") != -1)
	{
		var dy = (targetY - this.y - 200)/20;
	}
	else
	{
		var dy = (targetY - this.y - 200)/20;
	}

//	this.x += dx;
	this.y += dy;

	//we don't want this script to run until we pass the safe lower limit,
	//so user can see the full preview sample especially at lower resolutions
	if (this.y > 673)
	{
		this.moveTo(this.x, this.y);
	}
	else
	{
		this.moveTo(this.x, 485);
	}

}
JSFX.MakeFloatingLayer = function(theDiv, x, y)
{
	JSFX.MakeFloatingLayer.floaters[JSFX.MakeFloatingLayer.floaters.length] = new JSFX.FloatingLayer(theDiv, x, y);
}
JSFX.MakeFloatingLayer.floaters = new Array();
JSFX.MakeFloatingLayer.animate = function()
{
	var i;
	for(i=0 ; i<JSFX.MakeFloatingLayer.floaters.length ; i++)
		JSFX.MakeFloatingLayer.floaters[i].animate();
}
setInterval("JSFX.MakeFloatingLayer.animate()", 30);