/*******************************************************************
*
* File    : JSFX_SpriteDemo2.js © JavaScript-FX.com
*
* Created : 2001/03/16
*
* Author  : Roy Whittle www.Roy.Whittle.com
*           
* Purpose : To create animated page sprites
*
* History
* Date         Version        Description
*
* 2001-03-17	1.0		created for javascript-fx
*
* History
* Date         Version        Description
*
* 2008/11/15     modified by RGJ for sprites from specific pics only
* from html
***********************************************************************/
/*
 * Class SpriteDemo2 extends Object
 */
JSFX.SpriteDemo2 = function(numSprites)
{
/*    if (NumberA1 == 11 || NumberA2 == 11 || NumberA3 == 11 || NumberA1 == 10 || NumberA2 == 10 || NumberA3 == 10) {
*/
    if (NumberA2 == 3 || NumberB1 == 45 || NumberB2 == 45 || NumberB1 == 46 || NumberB2 == 46 || NumberJ1 == 10) {
    numSprites = 1
	}
else {
    numSprites = 0
 	}
	var x;
	for(x=0 ; x<numSprites ; x++)
     	{
		mySprite = new JSFX.Sprite("images/johnshead8.gif",0,0, 80, 80);
		mySprite.dx=305;
		mySprite.dy=305;
		mySprite.animate = JSFX.SpriteDemo2.animate;
	}

	JSFX.Sprite.startSprites();
}
JSFX.SpriteDemo2.animate = function()
{
	var b = JSFX.Browser;

	this.x += this.dx;
	this.y += this.dy;

	if(this.x > b.getMaxX()-this.w)
	{
		this.x -= this.dx;
		this.dx = -(Math.random()*10 + 1);
	}
	else
	if(this.x < b.getMinX())
	{
		this.x -= this.dx;
		this.dx = (Math.random()*10 + 1);
	}

	if(this.y > b.getMaxY()-this.h)
	{
		this.y -= this.dy;
		this.dy = -(Math.random()*10 + 1);
	}
	else
	if(this.y < b.getMinY())
	{
		this.y -= this.dy;
		this.dy = (Math.random()*10 + 1);
	}

	this.moveTo(this.x, this.y);
}

