var progressSpinner = function(container, options) {
  
  var obj = {
    
    start: function() {
      var newWidth = function(t) {
        if(time < halfLife)
          return t * (containerWidth / 2) / halfLife;
        else
          return containerWidth * (1 - Math.exp(-1 * Math.LN2 * t / halfLife));
      }
      
      inProgress = setInterval(function() {
        bar.style.width = newWidth(time) + "px";
        time += (interval / 1000);
      }, interval);
    },
    
    
    finish: function(callback) {
      time          = 0;
      var initWidth = bar.offsetWidth;
      var remaining = container.offsetWidth - initWidth;
      var newWidth  = function(t) {return initWidth + (t * remaining / finishTime)};
      
      clearInterval(inProgress);
      
      inProgress = setInterval(function() {
        var width = newWidth(time);
        if(width >= container.offsetWidth) {
          clearInterval(inProgress);
          bar.style.width = '100%';
          callback();
        
        } else {
          bar.style.width = width + "px";
          time += (interval / 1000);
        }
        
      }, interval);
    }
    
  }
  
  
  options             = options             || {};
  halfLife            = options.halfLife    || 5;
  var bar             = $(options.bar)      || container.getElementsByClassName('bar')[0];
  var containerWidth  = (options.endPadding || .95) * container.offsetWidth;
  var interval        = options.interval    || 33;
  var finishTime      = options.finishTime  || 0.5;
  
  var inProgress      = null;
  var time            = 0;
  obj.start();
  
  return obj;
}