moved javascript out of the templates, fixes #249