/*
Arguments msecs = # of milesecons to run the before onexpire
Events onExpire + runs when the timer hits 0 
*/

 GoldmanSachs.Timer = new Class({
	msecs: 1000,
	onExpire : Class.empty,
	isRunning: false,
	initialize : function(msecs) {
		($defined(msecs))? this.msecs = msecs: null;
	},
	start : function () {
		var ref = this;
		this.isRunning = true;
		this.interval = setTimeout(function() {ref.fireExpire();}, this.msecs );
		return true;
	},
	stop : function () {
		this.isRunning = false;
		clearTimeout(this.interval);
		return true;	
	}, 
	restart : function () {
		this.stop();
		this.start();
		return true;
	}, 
	fireExpire : function () {
		this.stop();
		this.fireEvent('onExpire');
		return true;
	}
});
GoldmanSachs.Timer.implement(new Events);