move homepage javascript from template to js file