Split regions code to regions.js

Allows editing without messing up other commits.  Also allows porting
to future projects.