var fk_timerID = null,
    fk_timerRunning = false,
    fk_timerDiff,
    fk_lastTime,
    fk_clockObj;

function fk_showtime() {
  var now = new Date();
  now.setTime(now.getTime() - fk_timerDiff);

  var year = now.getYear(),
      hours = now.getHours(),
      minutes = now.getMinutes(),
      seconds = now.getSeconds();

  if (year < 200) {
    year  += 1900;
  }
  var timeValue = "";
  timeValue  += ((hours < 10) ? "  0" : "  ") + hours;
  timeValue  += ((minutes < 10) ? ":0" : ":") + minutes;
  timeValue  += ((seconds < 10) ? ":0" : ":") + seconds;
  if (timeValue != fk_lastTime) {
    if (fk_clockObj.tagName.toLowerCase() == 'input')
      fk_clockObj.value = timeValue;
    else
      fk_clockObj.update(timeValue);
    fk_lastTime = timeValue;
  }
}

function fk_startclock(yyyy, mm, dd, hh, min, sec) {
    if (fk_timerRunning) {
        clearInterval(fk_timerID);
    }
    fk_timerRunning = false;
    var server = new Date(yyyy, mm, dd, hh, min, sec),
        client = new Date();
    fk_timerDiff = client - server;
    fk_lastTime = '';
    fk_clockObj = $('clock-input') || $('clock');
    fk_timerID = setInterval(fk_showtime, 100);
    fk_timerRunning = true;
}
