Track external links
Fix potential exception in sim.js
Fix another potential exception
Fix potential race condition in initialising the client
Sharing of resources between psim.us and pokemonshowdown.com

This commit allows the new psim.us domain to use the cookies and
`localStorage` of play.pokemonshowdown.com. Teams and prefs are
initially loaded from the play.pokemonshowdown.com `localStorage` and
changes to teams and prefs are written back to the
play.pokemonshowdown.com `localStorage`.

This commit also implements a few other things for the new psim.us
domain (implemented by Zarel):

- URIs of the form serverid.psim.us load the server `serverid`
- the naked domain now loads the lobby
Fix /~~server/ URIs
Fix /~~server/lobby URI
Fix a bug in crossdomain resource sharing
Implement host-port.psim.us syntax

For example, you can connect to localhost port 8000 by visiting
http://localhost-8000.psim.us
Rewrite third-party servers to *.psim.us URI scheme
Fix Analytics code for psim.us
Better redirection of naked psim.us domain
Analytics crossdomain tracking
Fix for URIs not ending in /
Remove default port from *.psim.us URIs
Fix typo in last commit
More robust removal of default port
Add link to main website at top of client UI
Always load resources from play.pokemonshowdown.com

With the advent of the *.psim.us URI scheme, one problem was that
images and other resources were not cached across different servers
because each server had a different URI for the same resource. This
commit resolves the problem by loading all resources from
play.pokemonshowdown.com.
Fix bug involving empty `sid` data