CRM-13148 preparatory cleanup mostly moving js from tpl to js file

Haven't attempted to do the whole js lint / closure thing - just trying to extract js from smarty for now