var Counter = new Class({
	Implements: [Options,Events],
	options : {
		element	: 'counter',
		interval :5000,
		countnIterval : 1000,
		onInterval : $empty
	},	
	
	initialize : function(options)
	{
		this.setOptions(options);
		if($defined(options.onInterval))
			this.options.onInterval = options.onInterval;
		this.options.element = $(this.options.element);
		this.initSecs();
		this.options.element.set("text", this.secs);
		this.start();
	},
	start : function()
	{
		this.going = true;
		this.counter = this.count.periodical(this.options.countnIterval, this);
	},
	pause : function()
	{
		this.going = false;
		$clear(this.counter);
	},
	count : function()
	{
		this.secs -= 1;
		if(this.secs == 0)
		{
			this.initSecs();
			this.options.onInterval();
		}
		this.options.element.set("text", this.secs);
			
	},
	initSecs : function()
	{
		this.secs = this.options.interval / this.options.countnIterval;
	}
});
