Thanks. That put me on the right track.
Can any address the window.close issue (repeated below)?
The second issue I have is that window.close does not work after you open a popup like inserting an image. This problem exists in the example too. Anyone know why this is or if there is some other work around than catching the exception?