split out helper functions into a separate javascript file and move document.ready to the template file