moved all javascript from the template to its own file