function countdown() { var now = new Date(); var timeLeft = trgDate.getTime() - now.getTime(); if(timeLeft < 0) timeLeft = 0; var str = pad(Math.round(timeLeft/3600000)); timeLeft = timeLeft % (3600000); str = str + ':' + pad(Math.round(timeLeft/60000)); timeLeft = timeLeft % (60000); str = str + ':' + pad(Math.round(timeLeft/1000)); timeLeft = timeLeft % (1000); last_str = pad(Math.round(timeLeft/10)); if(last_str > 99) last_str = 99; // Make sure the value doesn't have 100 at the end - should only be 01-99 or the text "jumps" //str = str + ':' + pad(Math.round(timeLeft/10)); str = str + ':' + last_str; /* if(str.length > 11) str = str.substring(0,str.length-1); // Make sure the value doesn't have :100 at the end - should only be 01-99 or the text "jumps" */ document.getElementById(trgEl).innerHTML = str; }