var CountDown = {};
	var current="Expired"
CountDown.Base = new Class({
	options: {
		seconds: 0,
		minutes: 0,
		hours: 0,
		day: 0,
		month: 0,
		year: 0,
		todayy: 0,
		todaym: 0,
		todayd: 0,
		todayh: 0,
		todaymin: 0,
		todaysec: 0,
		jsToday: false,
		withDays: true

		
	},
	montharray: new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),
 	initialize: function(element,options) {
		this.element = element;
		if(options.jsToday){
			//alert('asd');
			var today=new Date()
			options.todayy= today.getYear()
			if (options.todayy < 1000)
			options.todayy+=1900
			options.todaym= today.getMonth()
			options.todayd= today.getDate()
			options.todayh= today.getHours()
			options.todaymin=today.getMinutes()
			options.todaysec=today.getSeconds()
			
		}else{
			options.todaym--;
		}
		
		this.setOptions(options);
		
		this.build();
		this.delayTimer = this.update.periodical(1000,this);
	
		//setTimeout("this.build();",1000)
		//futurestring=this.montharray[this.options.month-1]+" "+this.options.day+", "+this.options.year+" "+this.options.hours+":"+this.options.minutes+":"+this.options.seconds
		//alert(Date.parse(futurestring));
		futurestring = this.montharray[this.options.todaym]+" "+this.options.todayd+", "+this.options.todayy+" "+this.options.todayh+":"+this.options.todaymin+":"+this.options.todaysec
		//alert(Date.parse(futurestring));
	},
	update: function(){
		if(this.options.jsToday){
			var today=new Date()
			this.options.todayy= today.getYear()
			if (this.options.todayy < 1000)
			this.options.todayy+=1900
			this.options.todaym= today.getMonth()
			this.options.todayd= today.getDate()
			this.options.todayh= today.getHours()
			this.options.todaymin=today.getMinutes()
			this.options.todaysec=today.getSeconds()
		}else{
			this.options.todaysec++;
			if(this.options.todaysec>59){
				this.options.todaysec=0;
				this.options.todaymin++;
				if(this.options.todaymin>59){
					this.options.todaymin=0;
					this.options.todayh++;
					if(this.options.todayh>23){
						this.options.todayh=0;
						window.location.reload();
					}
					
				}
			}
		}
		this.build();
			//alert(today);
			
	},
	build: function (){
		//theyear=yr;themonth=m;theday=d
		/*var today=new Date()
		var todayy=today.getYear()
		if (todayy < 1000)
		todayy+=1900
		*/
		//this.options.todaysec++;
		//alert(this.options.todaysec);
		var todaystring=this.montharray[this.options.todaym]+" "+this.options.todayd+", "+this.options.todayy+" "+this.options.todayh+":"+this.options.todaymin+":"+this.options.todaysec
		futurestring=this.montharray[this.options.month-1]+" "+this.options.day+", "+this.options.year+" "+this.options.hours+":"+this.options.minutes+":"+this.options.seconds
		dd=Date.parse(futurestring)-Date.parse(todaystring)
		dday=Math.floor(dd/(60*60*1000*24)*1)
		dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
		dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
		dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
		if(dday==0&&dhour==0&&dmin==0&&dsec==1){
			document.getElementById('counter').style.display='none';
			document.getElementById('expired').style.display='block';
			 $clear(this.delayTimer);
			return
		}
		else{
			if(this.options.withDays){
				//alert(this.element);
				$(this.element+'_days').innerHTML=dday;
				$(this.element+'_hour').innerHTML=dhour;
				$(this.element+'_min').innerHTML=dmin;
				$(this.element+'_sec').innerHTML=dsec;
			}else{
				$(this.element+'_hour').innerHTML=(24*dday)+dhour;
				$(this.element+'_min').innerHTML=dmin;
				$(this.element+'_sec').innerHTML=dsec;
				
			}
			//this.delayTimer = this.build.delay(1000, this);
			//this.build();
			
		}
	}
 
		
		

});
CountDown.Base.implement(new Options);
