speed=1000;

var target_time;
var element_id;

function start()
{
	var now = new Date();
	var html;
	var second_left;

	second_left = Math.round(( target_time - now )/1000) ;

	if (second_left < 0)
	{
		html = "********";
	}else{
		sec = second_left%60;
		second_left = Math.floor( second_left/60);
		min = second_left %60 ;
		second_left = Math.floor(second_left / 60);
		hour = second_left %24 ;
		day = Math.floor(second_left / 24);
		if (day < 10 ) day = "0"+day;
		if (sec < 10 ) sec = "0"+sec;
		if (min < 10 ) min = "0"+min;
		if (hour < 10 ) hour = "0"+hour;
		html = day + "<small>D</small> " + hour + "<small>H</small> " + min + "<small>M</small> " + sec + "<small>S</small>";
	}
	output(html);
	tid=window.setTimeout("start()",speed);
}
function output(html)
{
	document.getElementById(element_id).innerHTML = html;	
}
function countdown(target, id)
{
	target_time = new Date(target);
	element_id = id;

	start(target);
}