/*******************************************************************
*
* File    : JSFX_Swing.js
*
* Created : 2008/06/23
*
* Purpose : To create animated swinging images on the page 
		using any user supplied image. Uses the JSFX_Sprite library.
*
***********************************************************************/
//!!!! 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 SwingSprite extends Layer
 */

var xmin = 0; //324; //700

var xmax = 995 - 135;

JSFX.SwingSprite = function(img, dx, y, op)
{
	//Call the superclass constructor
	var theHtml = "<IMG src='"+img+"'>";
	this.superC	= JSFX.Layer;
	this.superC(theHtml);

	this.x = xmax;
	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.SwingSprite.prototype = new JSFX.Layer;

JSFX.SwingSprite.prototype.animate = function()
{
	this.x += this.dx;
	this.y += this.dy;

	if(this.dx < 0 && this.x < xmin )
	{
		this.x = xmin;
		this.dx = - this.dx;
	}
	else if (this.dx > 0 && this.x > xmax)
	{
		this.x = xmax;
       this.dx = - this.dx;
	}
	this.moveTo(this.x, this.y);
}
JSFX.AddSwingImg = function(img, dx, y, op)
{
	var mySprite
	var sp = JSFX.AddSwingImg.sprites;
	sp[sp.length]  = new JSFX.SwingSprite(img, dx, y, op);

	if(!JSFX.AddSwingImg.started)
	{
		JSFX.AddSwingImg.started = true;
		JSFX.AddSwingImg.animate();
	}
}
JSFX.AddSwingImg.sprites = new Array();
JSFX.AddSwingImg.started = false;
JSFX.AddSwingImg.animate = function()
{
	setTimeout("JSFX.AddSwingImg.animate()", 40);
	var sp = JSFX.AddSwingImg.sprites;
	var i;
	for(i=0 ; i<sp.length ; i++)
		sp[i].animate();

}


