Add basic support for Page Visibility API

Stop slideshow, when user is using another tab, resume when comes back
Reorganise code, handle prerendering