var Countdown = function(){
  function count(el){
    var time_left = el.getAttribute('data-time');
    update(el,time_left)
    setInterval(function(){
      time_left -= 1;
      update(el, time_left);
    }, 1000);
  }

  function update(el, time){
    el.update(seconds_to_words(time));
  }

  function seconds_to_words(seconds){
    var minutes = Math.floor(seconds / 60) % 60;
    var hours = Math.floor(seconds / 60 / 60) % 24;
    var days = Math.floor(seconds / 60 / 60 / 24);
    var seconds = seconds % 60;
    var days_text = ''
    if(days > 0) var days_text = days + ' ' + translations.days + ', ';
    return  days_text + zero_pad(hours) + ':' + zero_pad(minutes,2) + ':' + zero_pad(seconds,2)
  }

  function zero_pad(num,count){
    var num_zeropad = num + '';
    while(num_zeropad.length < count) {
      num_zeropad = "0" + num_zeropad;
    }
    return num_zeropad;
  }

  return {count : count}
}();