var months = new Array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
if (lang == "en")
  var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

function updateClock()
{
  var currentTime = new Date();

  // day
  var currentDay = currentTime.getDate();
  if (lang == "en") {
    if (currentDay == 1)
      currentDay += "st";
    else if (currentDay == 2)
      currentDay += "nd";
    else if (currentDay == 3)
      currentDay += "rd";
    else
      currentDay += "th";
  } else {
    currentDay += ".";
  }

  // month
  var currentMonth = months[currentTime.getMonth()];
  if (lang == "en") {
    currentMonth = currentMonth.substr(0, 3);
  }

  // year
  var currentYear = currentTime.getFullYear();

  // time
  var currentHours = currentTime.getHours();
  var currentMinutes = currentTime.getMinutes();
  var currentSeconds = currentTime.getSeconds();

  // leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // display strings
  var currentDateString = currentDay + " " + currentMonth + " " + currentYear;
  if (lang == "en") {
    var currentDateString = currentMonth + " " + currentDay + " " + currentYear;
  }

  var currentTimeString = currentHours + "std " + currentMinutes + "min " + currentSeconds + "sek";
  if (lang == "en") {
    var currentTimeString = currentHours + "hrs " + currentMinutes + "mins " + currentSeconds + "secs";
  }

  // update display
  $("#date").text("Berlin " + currentDateString + "\n________________________________________");
  $("#time").text(currentTimeString + "\n________________________________________");
}

// start clock
$(document).ready(function() {
	updateClock();
  setInterval('updateClock()', 1000);
});

