function foreachin(object, fn, opt_all) {
  for (var i in object) {
    if (opt_all || !object.hasOwnProperty || object.hasOwnProperty(i)) {
      fn(i, object[i]);
    }
  }
}
Safely iterates over all properties of the given object, calling
the given function for each property. If opt_all isn't true, uses
hasOwnProperty() to assure the property is on the object, not on
its prototype.

@param {Object} object
@param {Function} fn
@param {Boolean} opt_all  If true, also iterates over inherited properties.