function clockObj(id) {
	this.clockFace = document.getElementById(id);
	if (this.clockFace != null) {
		var clientDate = new Date();
		var serverDate = new Date();
		var serverTimeArray = serverTime.split(":");
			serverDate.setHours(serverTimeArray[0]);
			serverDate.setMinutes(serverTimeArray[1]);
			serverDate.setSeconds(serverTimeArray[2]);
		this.dateDiff = serverDate.getTime() - clientDate.getTime();
		this.ref = "ref" + id + "Object"; 
    eval(this.ref + "=this");
		delete serverDate, clientDate;
	}
	return this;
}

clockObj.prototype.tickTock = function() {
	if (this.clockTimeout) clearTimeout(this.clockTimeout);
	var clientDate = new Date();
		clientDate.setTime(clientDate.getTime() + this.dateDiff);
	if (!isNaN(clientDate.getHours())) {
		this.clockFace.innerHTML = adjustTime(clientDate.getHours())+ ":" + adjustTime(clientDate.getMinutes()) + ":" + adjustTime(clientDate.getSeconds());
		delete clientDate;
			this.clockTimeout = setTimeout(this.ref + ".tickTock()", 1000)
	} else this.stop();
}

function adjustTime(unit) {
	return (parseInt(unit) < 10) ? ("0" + unit) : unit;
}

clockObj.prototype.clockTimeout = false;
clockObj.prototype.stop = function() {
	if (this.clockTimeout) clearTimeout(this.clockTimeout);
	if (this.clockFace != null) this.clockFace.innerHTML = "";
}