
var eimTimeWidget = function() {
	var ntpTimestamp = 1776779564000;
	var ntpTimeObject    = new Date(ntpTimestamp);
	var clientTimeObject = new Date();

	function pad2(number) { 
	     return (number < 10 ? "0" : "") + number;
	}
	function returnDate(timestamp) {
		obj = new Date(timestamp);
		return obj.getHours() + ":" + pad2(obj.getMinutes()) + ":" + pad2(obj.getSeconds());
	}
	function updateTime() {
		$("#widget-national-time").html(returnDate(ntpTimestamp));
		ntpTimestamp += 1000;
		setTimeout(updateTime, 1000);
	}

	document.write("<div style=\"background: #FFF; width: 200px; height: 145px; text-align: center; border: 2px solid #00698C; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; box-shadow: 1px 1px 1px #CCC; -moz-box-shadow: 1px 1px 1px #CCC; color: #00698C; vertical-align: center; padding: 0; margin: 0; font-size: 1em;\"><div style=\"margin: 5px; padding: 0;\">");
	document.write("<a href=\"http://time.eim.gr\" style=\"display: block; font-size: 12pt; line-height: 24px; height: 54px; background: url('http://time.eim.gr/widget/eim35.jpg') top left no-repeat; padding: 0 0 0 64px; margin: 0; text-align: left; color: #00698C;\" title=\"Learn more at http://time.eim.gr\" />HELLENIC NATIONAL TIME</a>");
	document.write("<div id=\"widget-national-time\" style=\"text-align: center; font-size: 20pt; padding: 0; margin: 5px 5px 0 5px; text-shadow: 1px 1px 1px #CCC;\">" + returnDate(ntpTimeObject) + "</div>");
	document.write("<span style=\"font-size: 7pt\">Accuracy ~0.5 sec</span>");
	document.write("<a href=\"http://www.eim.gr\" style=\"color: #00698C; display: block; font-size: 8pt; text-decoration: underline; margin-top: 0;\">Hellenic Institute of Metrology</a>");
	document.write("</div></div>");

	updateTime();
}();
