/*******************************************************************
*
* File    : JSFX_floatImage.js © JavaScript-FX.com
*
* Created : 2001/06/21
*
* Author  : Roy Whittle www.Roy.Whittle.com
*           
* Purpose : To create animated floating left or right images on the page 
		using any user supplied image. Uses the JSFX_Sprite library.
*
* History
* Date         Version        Description
*
* 2001-06-21	1.0		Created for javascript-fx
***********************************************************************/
//!!!! First thing we need to do is disable opacity for Netscape 6 to
//!!!! stop it crashing in the GKGFXWIN.DLL !!!!!!!!!!!
if(navigator.appName.indexOf("Netscape") != -1)
{
	JSFX.Layer.prototype.setOpacity = function(pc) {return 0;}
}
//!!!! Try taking the above lines out and watch NS6 CHOKE!!!

JSFX.AddFloatImg = function(img, dx, y, op)
{
	var floatImage = null;

	floatImage = new JSFX.Sprite(img);
	floatImage.op = op;
	floatImage.x = Math.random()*JSFX.Browser.getMaxX();
	floatImage.y = y
	floatImage.dx = dx;
	floatImage.dy = 0;
	floatImage.w = 30;
	floatImage.h = 30;
	floatImage.animate = JSFX.animateFloatImg;
	floatImage.setOpacity(op);
	floatImage.moveTo(floatImage.x,floatImage.y);
	JSFX.Sprite.startSprites();
}
JSFX.animateFloatImg = function()
{
	this.x += this.dx;
	this.y += this.dy;

	if(this.dx < 0 && this.x < -this.getWidth())
		this.x = JSFX.Browser.getMaxX();
	else if (this.x > JSFX.Browser.getMaxX())
	{
		this.x = -this.getWidth();
	}
	this.moveTo(this.x, this.y);
}
