Ignacio, Dear Hero member,
the little script you posted apparently works for all documents BUT it breaks the "my Account" window.
The error I get is:
Fatal error: Call to undefined method User::getViewUrl() in /var/www/opengoo/application/hooks/new_window_hook.php on line 5
I presume that's just a simple "if" missing!?