I have a script that sends a time-sensitive notification to users when there is a new question directed to them. However, I found that some people leave their computers open and go grab lunch, therefore missing notifications.
I'm looking to put together a script that detects if the user is idle for 5 minutes, and if so, it would show them as 'offline' and close down notifications. 
I was curious if it is possible to detect inactivity even across tabs? (for example if a user switches to another tab to Facebook.com and stays active there, they would be seen as 'active' even though they are not on our webpage specifically).
Store their last activity in a database table when they are active.  You can use mouse movement, keypresses, or some other activity to update the timestamp.  Periodically poll that table with an ajax call on the page on which the user would see their online/offline status.  If the last active time is > 5 minutes, show them as offline or idle.
Is it possible to detect idle time even across tabs?