Move as much script out of templates as possible, so that jshint can run and gettext strings are reduced.
Fixing scripting nits for @aronasorman.
Merge pull request #1923 from bcipolli/1918

Move as much script out of templates as possible, so that jshint can run, and gettext strings are reduced.