var Countdown = new Class({	options: {		countplus: true,
		days: true, 
		hours: true, 
		minutes: true, 
		seconds: true, 
		target: false, 
		formatDays: "%days% days ", 
		formatHours: "%hours% hours ", 
		formatMinutes: "%minutes% mins ", 
		formatSeconds: "%seconds% secs", 
		message: "Expired",
		onTick: Class.empty, 
		onComplete: Class.empty
	}, 
	initialize: function (el, options) {		this.setOptions(options);			this.el = el;			this.now = Math.round($time() / 1000);			this.target = (new Date(el.innerHTML)).getTime() / 1000;			if (this.target == "NaN") {				return;			}		if (!this.target) {	return;	}		this.remaining = this.target - this.now;			if (this.remaining < 0 && this.options.countplus == false) {
				this.done();				return;			}				this.tick();			}, 
	tick: function () {			var remaining = this.remaining;				this.getTime();				this.display(this.time);			if (this.remaining <= 0 && this.options.countplus == false) {
					this.done();					return;			}			if (remaining != this.remaining) {				this.fireEvent("onTick", this.time);			}			(function () {	this.tick(); }.bind(this).delay(500));	}, 
	getTime: function () {		var day = 86400;			var hour = 3600;			var minute = 60;			this.remaining = this.target - Math.round($time() / 1000);			if (this.remaining <= 0) {		this.remaining = this.target - Math.round($time() / 1000);			this.remaining = this.remaining * -1;			var days = this.options.days ? Math.floor(this.remaining / day) : 0;			var hours = this.options.hours ? Math.floor((this.remaining - days * day) / hour) : 0;			var minutes = this.options.minutes ? Math.floor((this.remaining - days * day - hours * hour) / minute) : 0;			var seconds = this.options.seconds ? this.remaining - days * day - hours * hour - minutes * minute : 0;			}		 else {		var days = this.options.days ? Math.floor(this.remaining / day) : 0;			var hours = this.options.hours ? Math.floor((this.remaining - days * day) / hour) : 0;			var minutes = this.options.minutes ? Math.floor((this.remaining - days * day - hours * hour) / minute) : 0;			var seconds = this.options.seconds ? this.remaining - days * day - hours * hour - minutes * minute : 0;			}		this.time = {days: days, hours: hours, minutes: minutes, seconds: seconds};	}, 
	display: function () {			this.el.set('html',this.format());		}, 
	pad: function pad(number, length) {
   		var str = '' + number;
		while (str.length < length) {
			str = '0' + str;
		}	   
		return str;

	},

	format: function () {		var str = "";		if (this.time.days > 0 || this.options.days == true) {		str += this.options.formatDays.replace("%days%", this.time.days);			}		if (this.time.days > 0 || this.time.hours > 0 || this.options.hours == true) {		str += this.options.formatHours.replace("%hours%", this.time.hours);			}		if (this.time.days > 0 || this.time.hours > 0 || this.time.minutes > 0 || this.options.minutes == true) {		str += this.options.formatMinutes.replace("%minutes%", this.time.minutes);			}		str += this.options.formatSeconds.replace("%seconds%", this.time.seconds);			return str;	}, 
	done: function () {		this.el.set('html',this.options.message);		this.fireEvent("onComplete", this.options.message);	}});		
    Countdown.implement(new Options);		
    Countdown.implement(new Events);		