Can I make the Viewer Panel Open/Close, when a media file is Selected/Deselected?

read this How to use buttons and scripts from this forum - Buttons/Scripts - Directory Opus Resource Centre (dopus.com)
to understand 'button scripts' and 'scripts'.