Moved Flash detection to JS.

Added new 'deactivatedFlash' and 'overdueFlash' events.

Fixes #138.
Fixes #255.