var serverClock = jQuery("#currentTime");
 
if (serverClock.length > 0) {
 
    showServerTime(serverClock, serverClock.text());
 
}

function showServerTime(obj, time) {
 	'use strict';
	
    var parts   = time.split(":"),
        newTime = new Date(),
        timeDifference  = new Date().getTime() - newTime.getTime();
 
    newTime.setHours(parseInt(parts[0], 10));
    newTime.setMinutes(parseInt(parts[1], 10));
    newTime.setSeconds(parseInt(parts[2], 10));
 
    var methods = {
 
        displayTime: function () {
 
            var now = new Date(new Date().getTime() - timeDifference);
 
            obj.text([
 
                methods.leadZeros(now.getHours(), 2),
                methods.leadZeros(now.getMinutes(), 2),
                methods.leadZeros(now.getSeconds(), 2)
 
            ].join(":"));
 
            setTimeout(methods.displayTime, 500);
 
        },
 
        leadZeros: function (time, width) {
 
            while (String(time).length < width) {
                time = "0" + time;
            }
            return time;
 
        }
    };
    methods.displayTime();
}