Changed from window focus/blur to document events.