modularize main.js & javascript.js -> functions.js

functions.js
common functions that could be used by any pages

main.js
functions specific for main page