var myCountdown=new Array();
var repeat=false;
var mycountdown=new Countdown();
with (mycountdown){
	tagID="countdown";
	setEventDate(2007,3,23,17,0,0);
	event="I-CON 26!";
	onevent="See you at the con!";
	afterevent="See you at the con!";
}
myCountdown[myCountdown.length]=mycountdown;
function checkPlural(noun,value){
	noun=(value==1)?noun:(noun+="s");
	return noun;
}
function updateDisplay(text,id){
	var tag=document.getElementById(id);
	if (tag.firstChild)
		tag.firstChild.nodeValue=text;
	else {
		textNode=document.createTextNode(text);
		tag.appendChild(textNode);
	}
	return;
}
function doCountdown(){
	for (i=0;i<myCountdown.length;i++){
		if (!myCountdown[i].expired){
			var currentDate=new Date();
			var eventDate=myCountdown[i].eventDate;
			var timeLeft=new Date();
			timeLeft=eventDate-currentDate;
			daysLeft=Math.floor(timeLeft/86400000);
			hoursLeft=Math.floor((timeLeft%86400000)/3600000);
			minsLeft=Math.floor(((timeLeft%86400000)%3600000)/60000);
			secsLeft=Math.floor((((timeLeft%86400000)%3600000)%60000)/1000);
			day=checkPlural("day",daysLeft);
			hour=checkPlural("hour",hoursLeft);
			minute=checkPlural("minute",minsLeft);
			second=checkPlural("second",secsLeft);
			if ((daysLeft==0)&&(hoursLeft==0)&&(minsLeft==0)&&(secsLeft==0))
				updateDisplay(myCountdown[i].onevent,myCountdown[i].tagID);
			else{
				if (daysLeft<=-1){
					updateDisplay(myCountdown[i].afterevent,myCountdown[i].tagID);
					myCountdown[i].expired=true;
				}else{
					updateDisplay(daysLeft+" "+day+" "+hoursLeft+" "+hour+" "+minsLeft+" "+minute+ ", and "+secsLeft+" "+second+" left until "+myCountdown[i].event,myCountdown[i].tagID);
					repeat=true;
				}
			}
		}
	}
	if (repeat){
		repeat = false;
		window.setTimeout("doCountdown()",1000);
	}else
		return;
}
function setEventDate(year,month,day,hour,minute,second){
	this.eventDate=new Date(year,month-1,day,hour,minute,second);
	return;
}
function Countdown(){
	this.tagID = "";
	this.eventDate = new Date();
	this.setEventDate = setEventDate;
	this.event = "";
	this.onevent = "";
	this.afterevent = "";
	this.expired = false;
}
