Moved javascript out of template and into separate file.