If that is not really an option you can always create an extension based on HttpRequestHandler to do that.
To declare a global variable you just need to put a
and then when opening the popup do
myPopupWindow = window.open( ...
without the var.
You just need to replace return true by return false in both buttons.
An option would be to change the button method to Ajax.
You need to remove the return statements from both onclick extended properties for you example to work.