var x = 0;

function getTime(serverDate, CountdownDate) {
x+=1;
now = new Date(serverDate.getTime() + x*1000);
later = new Date(CountdownDate);

days = (later - now) / 1000 / 60 / 60 / 24;
daysRound = Math.floor(days);
hours = (later - now) / 1000 / 60 / 60 - (24 * daysRound);
hoursRound = Math.floor(hours);
minutes = (later - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
minutesRound = Math.floor(minutes);
seconds = (later - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
secondsRound = Math.round(seconds);

if (secondsRound<10) {
	secondsRound='0' + secondsRound;
}
if (minutesRound<10) {
	minutesRound='0' + minutesRound;
}
if (hoursRound<10) {
	hoursRound='0' + hoursRound;
}


if (secondsRound == '01') {
	strsecond = 'second';
} else {
	strsecond = 'seconds';
}

if (minutesRound == '01') {
	strminute = 'minute';
} else {
	strminute = 'minutes';
}

if (hoursRound == '01') {
	strhour = 'hour';
} else {
	strhour = 'hours';
}

if (daysRound == '1') {
	strday = 'day';
} else {
	strday = 'days';
}

if (later > now) {

	ChangeCountdown(daysRound + ' ' + strday + ', ' + hoursRound + ' ' + strhour + ', ' + minutesRound + ' ' + strminute + ' and ' + secondsRound + ' ' + strsecond);
	} else {
		ChangeCountdown('')
	}
	newtime = window.setTimeout("getTime(serverDate,countdownDate);", 1000);
}

function ChangeCountdown(NewText) {
   var newtitle = NewText;
   var head1 = document.getElementById("countdown");
   head1.firstChild.nodeValue=newtitle;
}

