Split JavaScript and only loaded it on pages that need it

Also added pagetemplate for highlighting current page in nav