Split perk calculation into separate groovy script and fixed run time errors
Removed common dialog JS from profile to keep code dry