Clean up the JS and simplify it

Moved the JS to the bottom of the page (refer to commit c4513da). I
removed the $(document).ready because as the JS is at the bottom of the
page the page has “loaded” and so the elements can be referenced in the
JS code.