move javascript out of index.html into main.js