var clockManager = 
{
	bloc: false,

	init: function()
	{
		this.bloc = blocManager.createBloc("clockBloc", "Clock", "", function() {clockManager.close();}, 0, 0, 150, 100, 150, 60, 150, 100);
		var display = dom.addElement(this.bloc.contentElement, "span");
		display.id = "clockDisplay";

		this.getTime();
	},
	
	getTime: function()
	{
		if (this.bloc)
		{
			var thetime = new Date();
			var minutes = this.format(thetime.getMinutes());
			var hours = this.format(thetime.getHours());
			var seconds = this.format(thetime.getSeconds());
			
			var contentDiv = dom.get("clockDisplay");
			dom.emptyElement(contentDiv);
			dom.addText(contentDiv, hours + ":" + minutes + ":" + seconds);
			window.setTimeout("clockManager.getTime()", 1000);
		}
	},
	
	format: function(value)
	{
		if (value < 10)
		{
			return "0"+ value;
		}
		else
		{
			return value;
		}
	},
	
	close: function()
	{
		blocManager.removeBloc(this.bloc);
		this.bloc = false;
		moduleManager.unloadModule("clock");
	}
}

function clockInit()
{
	clockManager.init();
}
