/*
 * Class PlayField extends Object
 */

JSFX.PlayField = function(interval)
{
	this.sprites  = new Array();
	this.id 	  = "window."+this.getId();
	this.interval = interval;
	this.theTimer = null;

	eval(this.id + "=this");
}
//Static methods
JSFX.PlayField.Count = 0;
JSFX.PlayField.prototype.getId = function()
{
	return("pf"+JSFX.PlayField.Count++);
}
//Methods
JSFX.PlayField.prototype.start = function()
{
	if(this.theTimer == null)
		this.theTimer = setTimeout(this.id+".animate()", this.interval);
}
JSFX.PlayField.prototype.stop = function()
{
	if(this.theTimer != null)
	{
		clearInterval(this.theTimer);
		this.theTimer = null;
	}
}
JSFX.PlayField.prototype.animate = function()
{
	this.theTimer = setTimeout(this.id+".animate()", this.interval);
	var sp = this.sprites;
	var i;
	for(i=0 ; i<sp.length ; i++)
		sp[i].animate();
}
JSFX.PlayField.prototype.addSprite = function(sprite)
{
	this.sprites[this.sprites.length] = sprite;
}
JSFX.pf = new JSFX.PlayField(40);