Simplified more of the javascript with JQuery and deleted some unnecessary lines