window.addEvent('domready', function() {
	
	
		
		        //element: The element that will contain the countdown text
                //start: The starting number (defaults to 10)
                //finish: The ending number (defaults to 0)
                //duration: Duration between numbers (defaults to 1000, or 1 second)
                //startFont: The starting text font-size
                //finishFont: The ending text font-size
		
		        var CountDown = new Class({

                	//implements
                	Implements: [Options,Events],

                	//options
                	options: {
                		element: 'cdown',
                		start: 1000,
                		finish: 0,
                		startFont: '12px',
                		finishFont: '12px',
                		onComplete: $empty,
                		duration: 1000
                	},

                	//initialization
                	initialize: function(options) {
                		//set options
                		this.setOptions(options);
                	},

                	//get things started
                	start: function() {
                		this.anim();
                	},

                	//animate!
                	anim: function() {
                	    
                	    var daysLeft = parseInt(this.options.start / 86400);
                    	var hoursLeft = parseInt((this.options.start % 86400) / 3600);
                    	var minutesLeft = parseInt((this.options.start % 3600) / 60);
                    	var secondsLeft = this.options.start % 60;
                	    this.options.start--;
                	    
                	    if (daysLeft>0)
                	    {
                		    this.options.element.set('text',daysLeft+'d '+hoursLeft+'h '+minutesLeft+'m '+secondsLeft+'s');
                		} else {
                		    this.options.element.set('text',hoursLeft+'h '+minutesLeft+'m '+secondsLeft+'s');
                		}
                		
                		var fx = new Fx.Tween(this.options.element,{
                			duration: this.options.duration,
                			link: 'ignore',
                			onComplete: function() {
                				if(this.options.start >= this.options.finish) {
                					this.anim();
                				} else {
                					this.fireEvent('complete');
                				}
                			}.bind(this)
                		}).start('font-size',this.options.startFont,this.options.finishFont);
                	}
                });

             
		        var cd = new CountDown({
            		element: $('cdown'),
            		start: remainingtime,
            		finish: 0,
            		onComplete: function() {
            			this.options.element.set('text','Ended').setStyle('color','#fff');
            		}
            	}).start();
		
		
		
		
		
		
});