nmdgf.widgets.LiveClock = function(serverTimeString, elementId) {
	this.currentTime = new Date(serverTimeString);
	this.elementId = elementId;
	nmdgf.addOnLoad(this.initialize, this);
};

nmdgf.widgets.LiveClock.prototype = {
	
	currentTime : null,
	
	elementId : null,
	
	initialize : function() {
		var that = this;
		setInterval(function() {
			that.displayTime();
		}, 1000);
	},
	
	displayTime : function(){
		this.currentTime.setSeconds(this.currentTime.getSeconds()+1);
		var timestring = this.padLength(this.currentTime.getHours())+":"+this.padLength(this.currentTime.getMinutes())+":"+this.padLength(this.currentTime.getSeconds())
		nmdgf.byId(this.elementId).innerHTML=timestring
	},
	
	padLength : function(value){
		return (value.toString().length==1)? "0"+value : value;
	}
		
};
