
Clock = {
	clock : 0,
	objOra : document.getElementById('ora'),
	objData : document.getElementById('data'),
	twoDigits : function (number) {
		return (number < 10) ? '0' + number : number;
	},
	update : function () {
		if (this.clock) {
			clearTimeout(this.clock);
			this.clock = 0;
		}
		date = new Date();
		
		this.objOra.innerHTML = this.twoDigits(date.getHours()) + ":" +
							 	this.twoDigits(date.getMinutes()) + ":" +
							 	this.twoDigits(date.getSeconds());
		this.objData.innerHTML = this.twoDigits(date.getDate()) + "." +
							 	 this.twoDigits((date.getMonth() + 1)) + "." +
							 	 date.getFullYear();
		this.clock = setTimeout("Clock.update()", 1000);
	},
	start : function () {
		this.clock = setTimeout("Clock.update()", 100);
	},
	end : function () {
		if (this.clock) {
			clearTimeout(this.clock);
			this.clock = 0;
		}
	}
}

window.unload = Clock.end();
Clock.start();
