Move functions up a scope so they can be called from anywhere (e.g. the
buttons only need to be hooked up once -- at initial page load).