var clock = null;
var hello = null;
var lasthello = "";
var username = "";
// var greetings = new Array("Goedenacht", "Goedemorgen", "Goedemiddag", "Goedenavond");
var periods = new Array(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3);
var lastperiod = -1;

function timer()
{
	var now = new Date();
	var day = now.getDate();
	var month = now.getMonth() + 1;
	var year = now.getFullYear();
	var h = now.getHours();
	if(clock)
	{
		var hr = h;
		var m = now.getMinutes();
		var s = now.getSeconds();
		if(hr < 10)
		{
			hr = "0" + hr;
		}
		if(m < 10)
		{
			m = "0" + m;
		}
		if(s < 10)
		{
			s = "0" + s;
		}
		clock.innerHTML = day + "-" + month + "-" + year + " &nbsp; " + hr + ":" + m + ":" + s;
	}
	if(hello)
	{
		var n = periods[h];
		if(n != lastperiod)
		{
			lastperiod = n;
			hello.innerHTML = greetings[n] + " " + username;
		}
	}
}
function timeinit()
{
	hello = document.getElementById("hello");
	if(hello)
	{
		var a = hello.innerHTML.split(" ");
		a.shift()
		username = a.join(" ");
	}
	clock = document.getElementById("clock");
	if(clock || hello)
	{
		timer();
		setInterval('timer()', 1000);
	}
}
window.inits['time'] = timeinit;

