/*
** Magic-Tours clock-script
** (c) by Johannes Ernesti 2007
*/


// which element is the clock?
var CLOCK_ID = "main_clock";

var days = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Fehler");

// determins, if there should be a splitter between the hour and the minutes (changes every second)
var splitter = ":";

function make2Digits(num)
    {
    return num < 10 ? "0" + num : num;
    }

function updateClock()
    {
    var now = new Date(),
        day = make2Digits(now.getDate()),
        month = make2Digits(now.getMonth() + 1),
        year = "" + now.getFullYear(),
        min = make2Digits(now.getMinutes()),
        hour = make2Digits(now.getHours());

    var clock = document.getElementById(CLOCK_ID);
    clock.firstChild.nodeValue = days[now.getDay()] + ", " + day + "." + month + "." + year.substr(2, 2) + " " + hour + splitter + min + " Uhr";

    splitter = splitter == ":" ? " " : ":";
    }

window.setInterval("updateClock()", 1000);