rendered paste bodyCountDown = function(){ this.date = !(this.finished = this.paused = false);}CountDown.prototype.start = function(n, e, t, r){ var o = this; r ? o.onResume && o.onResume(o.n) : (o.n = o.date ? new Date(n).getTime() : n, o.e = o.date ? new Date(e).getTime() : e, o.t = t, o.finished = false, o.onStart && o.onStart(o.n)); o.d = e < n ? 1 : -1, o.paused = false, o.i = setInterval(function(){ o.d * (o.n -= o.d * (o.date ? 1e3 : 1)) <= o.e * o.d && (o.finished = !o.stop()) && !clearInterval(o.i) || o.onUpdate && o.onUpdate(o.n); }, (o.t || 1) * 1e3);}CountDown.prototype.pause = function(t){ var o = this; clearTimeout(o.x), o.paused ? o.start(o.n, o.e, o.t, 1) : (o.paused = !clearInterval(o.i), o.onPause && o.onPause(o.n), t && (o.x = setTimeout(function(){ o.start(o.n, o.e, o.t, 1); }, t * 1e3)));}CountDown.prototype.stop = function(){ var o = this; clearInterval(o.i), clearTimeout(o.x), o.onStop && o.onStop(o.n), o.n = 0;}<input type="text" size="50" id="lala" /><script type="text/javascript">//<![CDATA[var b = document.getElementById("lala");var t = new CountDown();t.date = false;t.onStart = function(n){ b.value = n; b.disabled = false;}t.onUpdate = function(n){ b.value = n;}t.onStop = function(n){ b.value = "Finish: " + n + "!!!"; b.disabled = true;}t.onPause = function(n){ b.value = "Pause: " + n; b.disabled = true;}t.onResume = function(n){ b.value = n; b.disabled = false;}document.onclick = function(){ if(t.finished) t.start(5, 10); else t.pause(2);}t.start(10, 1);//]]></script>