function toCountString(sec) {
  if (sec <= 0) {
    return '00:00:00';
  }
  var day = Math.floor(sec / (1000*60*60*24));
  var hour = Math.floor(sec % (1000*60*60*24)/(1000*60*60)).toString().replace(/^(\d)$/, '0$1');
  var min = Math.floor(sec % (1000*60*60*24) / (1000*60) % 60).toString().replace(/^(\d)$/, '0$1');
  var msec = Math.floor(sec % (1000*60*60*24)%60%60%1000).toString().replace(/^(\d)$/, '0$1');
  var sec = Math.floor(sec % (1000*60*60*24) / 1000 % 60 % 60).toString().replace(/^(\d)$/, '0$1');
  return day + 'days ' + hour + ':' + min + ':' + sec + ':' + msec;
}
 
function updateCountdown(id, m, c) {
  var node = document.getElementById(id);
  if (!node) {
    return false;
  }
  for (var i = 0; i < node.childNodes.length; i++) {
    node.removeChild(node.childNodes[i]);
  }
  var count = toCountString(Math.floor(m - c));
  node.appendChild(document.createTextNode(count));
}


