Improve handling of JS environment detection under Browserify and browser add-ons

Depending on the environment under which Dropbox-js is used,
there will be different ways to:

 - Access web APIs like XMLHttpRequest, base64 encoding, typed arrays
   etc.
 - Export Dropbox functionality for use by other code - eg. via
   module.exports or a property on `window` or `self`
 - Import functionality for use by Dropbox-js - eg. via require()

Previously there was an assumption that Dropbox-js was running
under one of three main types of environment - a browser, Node.js
or a web worker. The code first detected one of these types of
environment and set all of the above facets accordingly.

This broke apps in hybrid environments like Browserify which provide
both the `window` object but also a Node.js-like module environment for
example.

This commit refactors environment setup to deal with each of the facets
of the environment (web API access, module export, module import)
separately.
Merge pull request #1 from robertknight/rob-browserify

Improve handling of JS environment detection under Browserify and browse...