$(document).ready(function() {
    var obj = null;
    var l = null;
    if ($('#zegar-timer').length == 1) {
        obj = $('#zegar-timer');
        l =  '{d<}{dn} {dl}{d>} {hn} {hl} {mn} {ml} {sn} {sl}';
    } else if ($('#zegar-timer-bottom').length == 1) {
        obj = $('#zegar-timer-bottom');
        l =  '{d<}{dn} d{d>} {hn} h {mn} m {sn} s';
    }

    if (obj != null) {
        obj.countdown( {
            until : zegarEndTime, layout : l, serverSync : function() {
                var time = null;
                $.ajax( {
                    url : '/page/time', async : false, dataType : 'text', success : function(text) {
                        time = new Date(text);
                    }, error : function(http, message, exc) {
                        time = new Date();
                    }
                });
                return time;
            }
        });
    }
});

