is there some way of detecting using javascript that a user has switched to a different tab in the same browser window. 
Additionally is there a way to detect a user has switched to a different window than the browser?
thank you
Trap the window.onblur event.
It's raised whenever the current window (or tab) loses focus.
Detect change of browser tabs with javascript