	
	var Countdown = new Class({
	
		Implements: Options,			
		
		options: {
			current_time		: '',
			end_time			: '',
			number_of_digits	: 6
		},
		
		initialize: function(options) {
			this.setOptions(options);
			
			var t = this.options.current_time.split(',');
			this.current_time = new Date(t[0],t[1],t[2],t[3],t[4],t[5]);
			
			var t = this.options.end_time.split(',');
			this.end_time = new Date(t[0],t[1],t[2]);	
			
			this.remaining_time = (this.end_time.getTime() - this.current_time.getTime()) / 1000;
			
			this.setTime();
			
			this.timer_function = function() { this.remaining_time -= 1; this.setTime(); };
			this.timer = this.timer_function.periodical(1000, this);
		},
		
		setTime: function() {
			
			if (this.remaining_time <= 0) {
				this.cancelTimer();	
			} else {
				this.seconds	= (this.remaining_time % 60).toInt();
				this.minutes	= ((this.remaining_time / 60) % 60).toInt();
				this.hours		= (((this.remaining_time / 60) / 60) % 24).toInt();
				this.days		= (((this.remaining_time / 60) / 60) / 24).toInt();
				
				//alert('days:' + this.days + 'hours:' + this.hours + ' minutes:' + this.minutes + ' seconds:' + this.seconds);
				if (this.options.number_of_digits > 6) 
					var string = this.numberString(this.days) + this.numberString(this.hours) + this.numberString(this.minutes) + this.numberString(this.seconds);
				else
					var string = this.numberString(this.hours) + this.numberString(this.minutes) + this.numberString(this.seconds);
					
				var string = string * 1;
							
				for (i=this.options.number_of_digits; i>0; i--) {
					var number = string % 10;
					$('digit_' + i).innerHTML = (typeof(number) == 'number' ? number : 0);
					string = (string / 10).toInt();
				}	
			}
		},
		
		cancelTimer: function() {
			for (i=this.options.number_of_digits; i>0; i--) {
				$('digit_' + i).innerHTML = '0';
			}
			$clear(this.timer);
		},
		
		numberString: function(number) {
			if (number < 10) 
				return '0' + number.toString();
			else
				return number.toString();
		}
	});