Moved all javascript code from html to a js file