/*******************************************************************
*
* 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
* 2001-12-10	1.1		Use JSFX_PlayField instead of JSFX_Sprite
***********************************************************************/
//!!!! 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!!!
/*
 * Class FloatSprite extends Layer
 */
JSFX.FloatSprite = function(img, dx, y, op)
{
	//Call the superclass constructor
	var theHtml = "<IMG src='"+img+"'>";
	this.superC	= JSFX.Layer;
	this.superC(theHtml);

	this.x = Math.random()*JSFX.Browser.getMaxX();
	this.y = y
	this.dx = dx;
	this.dy = 0;
	this.w = 30;
	this.h = 30;
	this.setOpacity(op);

	this.moveTo(this.x,this.y);
	this.show();
}
JSFX.FloatSprite.prototype = new JSFX.Layer;

JSFX.FloatSprite.prototype.animate = 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);
}
JSFX.AddFloatImg = function(img, dx, y, op)
{
	var mySprite
	var sp = JSFX.AddFloatImg.sprites;
	sp[sp.length]  = new JSFX.FloatSprite(img, dx, y, op);

	if(!JSFX.AddFloatImg.started)
	{
		JSFX.AddFloatImg.started = true;
		JSFX.AddFloatImg.animate();
	}
}
JSFX.AddFloatImg.sprites = new Array();
JSFX.AddFloatImg.started = false;
JSFX.AddFloatImg.animate = function()
{
	setTimeout("JSFX.AddFloatImg.animate()", 40);
	var sp = JSFX.AddFloatImg.sprites;
	var i;
	for(i=0 ; i<sp.length ; i++)
		sp[i].animate();

}



