Rearranged some js so variables for radio buttons have greater scope