    (function($) {

      var Countdown = function(opts) {
        this.el = $(opts.el);
        this.formatter = opts.formatter;
        this.label = opts.label;

        this.future = new Date();
        this.future.setTime(Date.parse(opts.future));

        this.tick();
      };
      
      Countdown.fn = Countdown.prototype;

      Countdown.fn.tick = function() {
        var diff, days, hours, minutes, seconds, today = this.now();

        diff = this.truncateDate(this.future).getTime() - this.truncateDate(today).getTime();

        if (diff <= 0) {
          this.el.remove();
          return;
        }
        
        diff = this.future.getTime() - today.getTime();

        days = Math.floor(diff / (24 * 60 * 60 * 1000));
        diff %= 24 * 60 * 60 * 1000;

        hours = Math.floor(diff / (60 * 60 * 1000));
        diff %= (60 * 60 * 1000);

        minutes = Math.floor(diff / (60 * 1000));
        diff %= (60 * 1000);

        seconds = Math.floor(diff / 1000);

        if (this.formatter) {
          this.el.html(this.formatter.call(this, this.label, days, hours, minutes, seconds));
        }

        window.setTimeout($.proxy(this, 'tick'), 1000);
      };

      Countdown.fn.truncateDate = function(date) {
        return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
      };
      
      Countdown.fn.now = function() {
        var now = new Date;
        now.setTime(Date.now());
        return now;
      };

      $.fn.countdown = function(options) {
        if (this.length) {
          var opts = $.extend({el: this}, $(this).data(), $.fn.countdown.defaults, options);
          new Countdown(opts);
        }
      };

      $.fn.countdown.defaults = {
        formatter: function(label, days, hours, minutes, seconds) {
          var days = (days.toString().length === 1) ? '0' + days.toString() : days.toString();
          var hours = (hours.toString().length === 1) ? '0' + hours.toString() : hours.toString();
          var minutes = (minutes.toString().length === 1) ? '0' + minutes.toString() : minutes.toString();
          var seconds = (seconds.toString().length === 1) ? '0' + seconds.toString() : seconds.toString();
          return label + ': ' + [days, hours, minutes, seconds].join(':');
        }
      };

      $(function() {
        $('#countdown').countdown({
        	formatter: function(label, days, hours, minutes, seconds) {
        		var days = (days.toString().length === 1) ? '0' + days.toString() : days.toString();
        		var hours = (hours.toString().length === 1) ? '0' + hours.toString() : hours.toString();
        		var minutes = (minutes.toString().length === 1) ? '0' + minutes.toString() : minutes.toString();
        		var seconds = (seconds.toString().length === 1) ? '0' + seconds.toString() : seconds.toString();
        		return label + '<em>' + [days, hours, minutes, seconds].join('<i>:</i>') + '</em>';
        	}
        });
      });

    })(jQuery);
