function countdown(untilDate, dispElement, finalMessage) { var theDate = Date.parse(untilDate); var theElement = document.getElementById(dispElement); var now = Date.parse((new Date()).toString()); var dd, dday, dhour, dmin, dsec dd = theDate - now; if (theElement) { if (dd <= 0) { theElement.innerHTML = finalMessage; } else { dday = Math.floor(dd/(60*60*1000*24)*1); dhour = Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1); dmin = Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1); dsec = Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1); theElement.innerHTML = dday + ":" + ((dhour < 10) ? "0" + dhour : dhour) + ":" + ((dmin < 10) ? "0" + dmin : dmin) + ":" + ((dsec < 10) ? "0" + dsec : dsec); } } setTimeout("countdown('" + untilDate + "','" + dispElement + "','" + finalMessage + "');", 1000); }