I have spent the whole of last night looking for a reliable javascript that pops up a small (possibly centered) window when the user exits the site (for another site) and for when he/she closes the site's main window.

Has anybody come across or is aware of a script that does all the above?