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

Glad i could help. May i ask you about your workflow/usecase for that? I dont see a reason for always closing the viewer when unselecting. I mean opening the first file in a windowed viewer seems fine. But then i simply could go back to the mainwindow. And reopening might take longer than having it open in the background and just displaying the new selection.
For going through images i make use of leo's viewer select script and two buttons in lister and standalone viewer with the same shortcut for viewing the selected image or selecting the viewed image (bringing the other window to the top).