Refactor javascript per Mary's suggestions.

More functional style without using inheritance.
Change submit links to buttons.