Adds popup management logic

Adds JavaScript to open and close popups.