moved some of the JS from index.html to index.js
moved all JS parts from index.html in index.js
added refPeriod to id