worked on CRM-12202, js code cleanup, move js call from php to js file