Reorganized PopupPanel code, tested for both video and image
Reorganize code in popupPanel again, I think it's clearer now.