Timer = Class.create();
Timer.prototype = {
	countValue : 0,
	counterFunc : function(){},
	option : {},
	initialize : function(func) {
		this.func = func;
	},
	sleep : function(time) {
		this.stop();
		var count = 0;
		while(count++ < time*1000);
	},
	setTick : function(tick) {
		this.tick = tick;
		this.countValue = tick/1000;
	},
	start : function() {
		this.stop();
		this.counter = setInterval(function() {
			this.countValue -= 1;
			if(this.countValue < 1) this.stop();
			this.counterFunc(this.option);
		}.bind(this), 1000);
		this.timer = setTimeout(this.func, this.tick || 1000);
	},
	iter : function() {
		this.timer = setInterval(function() {
			this.stop();
			this.func(this.option);
			this.iter();
		}.bind(this), this.tick || 1000);
	},
	stop : function() {
		if(null != this.timer) clearTimeout(this.timer);
		if(null != this.counter) clearInterval(this.counter);
	}
}
