/**
 * Function that updates a countdown label with a time difference broken down into
 * in days, hours, minutes, and seconds.
 *
 * @param {int} countdown is the number of seconds till till the target date
 * @param {string} displayElement is the id of the element to display the countdown
 */ 
function displayCountDown(countdown, displayElement) 
{
    var cd = document.getElementById(displayElement).childNodes[0];

    if (cd == null) return;
    
    if (countdown < 0) cd.nodeValue = "In progress"; 
    else {
	var secs = countdown % 60; 
	if (secs < 10) secs = '0'+secs;
	var countdown1 = (countdown - secs) / 60;
	var mins = countdown1 % 60; 
	if (mins < 10) mins = '0'+mins;
	countdown1 = (countdown1 - mins) / 60;
	var hours = countdown1 % 24;
	var days = (countdown1 - hours) / 24;
	
	cd.nodeValue = days + " day" + (days == 1 ? '' : 's') + ' : ' +hours+ 'h : ' +mins+ 'm : '+secs+'s';
		
	setTimeout('displayCountDown('+(countdown-1)+',\''+displayElement+'\');',999);
    }
}