var timer = {
	start: function(f, a, t)
	{
		var id = this.timers.length;
		
//		if (this.timers.length==0)
//			id = 0;
//		else
//		{
//			var i=0;
//			for (; i<this.timers.length&&this.timers[i]!=null; i++);
//			id = i;
//		}
		
		this.timers[id] = {id: setTimeout("timer.exec("+id+")", t), func: f, args: a };
		
		return id;
	},
	clear: function(id)
	{
		if (this.timers[id]!=null)
			clearTimeout(this.timers[id].id);
		this.timers[id] = null;
	},
	exec: function(id)
	{
		if (this.timers[id]!=null)
			this.timers[id].func(this.timers[id].args);
		
		this.timers[id] = null;
	},
	stop: function(id)
	{
		this.clear(id);
	},
	stopAll: function()
	{
		for (var i=0;i<this.timers.length;i++)
			if (this.timers[i]!=null)
			{
				clearTimeout(this.timers[i].id);
				this.timers[i] = null;
			}
	},
	
	timers: []
};
