$(document).ready(function()
  {
    stopclock = 0;
    //servertime.php is called every second to get time from server
   var refreshId = setInterval(function() 
   {
    $(window).focus(function() {
        stopclock = 0;
    });
    $(window).blur(function() {
        stopclock = 1;
    });
     if ($(window).scrollTop() < 20 && stopclock == 0) {
       $('#servertime').load('src/servertime.php?randval='+ Math.random());
     }
    }, 1000);
  });

