    var serverTimeDelta;

    function getServerTimeDelta() {
        var xmlHttp;
        if (!serverTimeDelta) {
            try {
                if (window.XMLHttpRequest) {
                    xmlHttp = new XMLHttpRequest();
                } else {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
            } catch (err1) {
                //IE
                try {
                    xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
                } catch (err2) {
                    console.log("cannot find Msxml2.XMLHTTP.")
                }
            }
            if (xmlHttp) {
                xmlHttp.open('HEAD', window.location.href.toString(), false);
                xmlHttp.setRequestHeader("Content-Type", "text/html");
                xmlHttp.send('');
                var serverDateTime = xmlHttp.getResponseHeader("Date");
                if (serverDateTime) {
                    var dateNow = new Date();
                    var serverDate = new Date(serverDateTime);
                    serverTimeDelta = serverDate.getTime() - dateNow.getTime();
                    if (!serverTimeDelta)
                        serverTimeDelta = 0;
                } else {
                    serverTimeDelta = 0;
                }
            } else {
                serverTimeDelta = 0;
            }
        }
        return serverTimeDelta;
    }