function zero(val) {
  if (val < 10) {
    return "0"+val;
  } else {
    return val;
  } // if-else
} // function

function ucfirst( str ) {
  var f = str.charAt(0).toUpperCase();
  return f + str.substr(1, str.length-1);
}

function displayDateTime() {

  if (!document.getElementById("clock")) {
    return;
  } // if

  days = new Array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
  now = new Date();
  weekday = now.getDay();
  day = zero(now.getDate());
  month = zero(now.getMonth()+1);
  year = now.getFullYear();
  hour = zero(now.getHours());
  minute = zero(now.getMinutes());
  second = zero(now.getSeconds());

  output = days[weekday]+", "+day+"."+month+"."+year+" "+hour+":"+minute+":"+second;
  document.getElementById("clock").innerHTML = output;
  return;

  html = "";

  for (i = 1; i < output.length; i++) {
    html += '<img src="/img/digits/'

    if (i == 1) {
      digit = output[0]+output[1];
    } else {
      digit = output[i];
    } // if-else

    if (digit == ".") {
       html += 'point';
    } else if (digit == ":") {
       html += 'hypen';
    } else if (digit == " ") {
      html += 'space';
    } else if (digit == ",") {
      html += 'comma';
    } else {
      html += digit;
    } // if-elseif-...-else
    html += '.gif"/>';
  } // for

  document.getElementById("clock").innerHTML = html;
} // function

window.onload = function() {
  displayDateTime();
  window.setInterval("displayDateTime()", 1000);
}


