Javascript changes

Create prescript and postscript blocks, and move all Javascript into either
- events or functions called by events (onclick, onchange, document.ready, etc.),
- the postscript block.

Then jquery can be moved to the end of the body, dropping the last render-blocking
javascript.