var DeferrableTimer = Class.create();

DeferrableTimer.prototype = {
	func_: null,
	timer_id_: null,
	timeout_: null,
	running_: null,
	arguments_: null,
	
	initialize: function(func_, timeout) {
		this.func_ = func_;
		this.timeout_ = timeout;
		this.running_ = false;
	},
	
	start: function() {
		if (this.running_) {
			clearTimeout(this.timer_id_);
		}
		this.arguments_ = arguments;
		this.running_ = true;
		this.timer_id_ = setTimeout(this.execute_.bind(this), this.timeout_);
	},
	
	execute_: function() {
		var result = this.func_.apply(this, this.arguments_);
		this.running_ = false;
		return result;
	} 
}
