function throttle(fn, timeout) {
  var timer = null;
  return function () {
    if (!timer) {
      timer = setTimeout(function() {
        fn();
        timer = null;
      }, timeout);
    }
  };
}
Throttles a function and delays its executiong, so it's only called at most
once within a given time period.
@param {Function} fn The function to throttle.
@param {number} timeout The amount of time that must pass before the
    function can be called again.
@return {Function} The throttled function.