Changed logic for show/hide PopupLayer