Add main-dom.js

Split off main.js, integrating formerly-separate documentation.