restructured code, added window title support for all browsers