$(window).focus(function() { AJAX запрос через setInterval });
if( isset( $_SESSION['timer'] ) AND $_SESSION['timer'] >= $timeout )
{
$_SESSION['timer'] = 0;
echo 'Good Work!';
} else {
$_SESSION['timer'] = $_SESSION['timer'] + 1;
}