Create a simple countdown object
/**
* Create and process a new Countdown object.
*
* @param seconds
* Integer
*/
function Countdown(seconds) {
$('#timer').html(seconds);
var timer = window.setInterval(function() {
if (seconds === 0) {
clearInterval(timer);
return;
}
seconds -= 1;
$('#timer').html(seconds);
}, 1000);
this.stop = function() {
clearInterval(timer);
}
}