/*
 * Class Sprite extends Layer
 */
JSFX.Sprite = function(theImage, x, y, w, h)
{
	if(!theImage)
		return;

	var imgName = JSFX.Sprite.getImgName();
	var extra  = "";
	if(w) extra += " WIDTH='"+w+"'";
	if(h) extra += " HEIGHT='"+h+"'";
	var htmlStr = "<IMG SRC='"+theImage+"' NAME='"+imgName+"'"+extra+">";

	this.oSuper = JSFX.Layer;
	this.oSuper(htmlStr, x, y);
	this.x = 0;
	this.y = 0;
	this.w = w;
	this.h = h;
	this.dx = 0;
	this.dy = 0;
	this.imgName = imgName;
	this.show();

	JSFX.Sprite.Sprites[JSFX.Sprite.Sprites.length] = this;
}
JSFX.Sprite.prototype = new JSFX.Layer;

//Class variables
JSFX.Sprite.Sprites = new Array();
JSFX.Sprite.theTimer = null;

//Static methods
JSFX.Sprite.getImgName = function()
{
	return("sp"+JSFX.Sprite.Sprites.length);
}
JSFX.Sprite.startSprites = function()
{
	if(JSFX.Sprite.theTimer == null)
	{
		JSFX.Sprite.theTimer = setTimeout("JSFX.Sprite.animateAll()", 40);
	}
}
JSFX.Sprite.stopSprites = function()
{
	if(JSFX.Sprite.theTimer != null)
	{
		clearInterval(theTimer);
		JSFX.Sprite.theTimer = null;
	}
}
JSFX.Sprite.animateAll = function()
{
	JSFX.Sprite.theTimer = setTimeout("JSFX.Sprite.animateAll()", 40);
	var sp = JSFX.Sprite.Sprites;
	var i;
	for(i=0 ; i<sp.length ; i++)
		sp[i].animate();

}
//Methods
JSFX.Sprite.prototype.setImg = function(theImage)
{
	this.images[this.imgName].src = theImage;
}
JSFX.Sprite.prototype.resizeTo = function(w,h)
{
	var htmlStr = "<IMG SRC='"+this.images[this.imgName].src+"' WIDTH='"+w+"' HEIGHT='"+h+"' NAME='"+this.imgName+"'>";
	this.w = w;
	this.h = h;
	this.setContent(htmlStr);
}
JSFX.Sprite.prototype.animate = function(){}

/**************************************************************************/
/*** If no other script has added it yet, add the ns resize fix ***/
if(navigator.appName.indexOf("Netscape") != -1 && !document.getElementById)
{
	if(!JSFX.ns_resize)
	{
		JSFX.ow = outerWidth;
		JSFX.oh = outerHeight;
		JSFX.ns_resize = function()
		{
			if(outerWidth != JSFX.ow || outerHeight != JSFX.oh )
				location.reload();
		}
	}
	window.onresize=JSFX.ns_resize;
}

