// MouseTrack v2.
// TimerClass
// Responsible for time management
// 2006 Will Wei
TimerClass = Class.create();

TimerClass.prototype = {
	
	// Constructor
	initialize : function() {
		// Time is stored in seconds
		this.time = 0;
		this.items = new Array();
		this.interval = 10; // In milliseconds

	},
	
	// elapsed: function
	// returns: the amount of time elapsed since the timer was told to track the item
	// i.e. a function will first call elapsedUpdate to start timing
	// then an elapsed call will return the time passed since elapsedUpdate was called
	elapsed : function(itemName) {
		return (this.time- (this.items[itemName] != "" ? this.items[itemName] : this.time)).toFixed(2);
	},
	
	// elapsedUpdate : function
	// no return value
	// Either updates time of the item or creates it
	elapsedUpdate : function(itemName) {
		this.items[itemName] = this.time;
	},
	
	// increment : function
	// Increments the time counter
	increment : function() {
		this.time+=this.interval/1000;
		
	},
		
	// remove : function
	// removes a certain item from the item stack
	// actually right now, only sets it to zero
	remove : function(itemName) {
		// For now, just set the time to false
		// Actually removing the element may prove less efficient than this
		this.items[itemName] = false;
	},
	
	// toString : function()
	// returns time elasped
	toString : function() {
		return this.time.toFixed(2);
	}
};
