/*
 * Class Wavy extends Object
 */
JSFX.Wavy = function(theImage, nx, ny, cx, cy)
{
	var myPlayField = new JSFX.PlayField(40);
	var x,y;
	for(x=0 ; x<nx ; x++)
		for(y=0 ; y<ny ; y++)
		{
			mySprite = new JSFX.WavyMoveSprite(theImage, x, y, cx, cy);
			myPlayField.addSprite(mySprite);
		}

	myPlayField.start();
}
/*
 * Class WavySprite extends Layer
 */
JSFX.WavyMoveSprite = function(theImage, x, y, cx, cy)
{
	var htmlStr = "<IMG SRC='"+theImage+"'>";

	this.superC = JSFX.Layer;
	this.superC(htmlStr,0,0);

	this.cx = cx + (15 * (x-y)    );
	this.cy = cy + (15 * (x+y)/2  );
	this.dx = 4;
	this.dy = 2;
	this.index=Math.sin(x/2)+Math.sin(y/2);
	this.show();

}
JSFX.WavyMoveSprite.prototype = new JSFX.Layer;

JSFX.WavyMoveSprite.prototype.animate = function()
{
	this.x = this.cx;
	this.y = this.cy + 15 * Math.sin(this.index);
	this.cx += this.dx;
	this.cy += this.dy;
	this.index+=0.2;
	this.moveTo(this.x, this.y);

	if(this.cx > JSFX.Browser.getMaxX()-40)
		this.cx=0;

	if(this.cy > JSFX.Browser.getMaxY()-50)
		this.cy=0;
}