Put Josh's new code into the JavaScript file. Fixed minor things.