function ClockControl(){
	oldS=0; se=0;
	var intervalID;
	var clocks = new Array();

	function addClock(clockID,offset) {
		for (var i = 0; i < clocks.length; i++){
			if (clocks[i][0] == clockID) alert ("Error on ClockControl.addClock(" + clockID +","+offset +")\n Duplicate Clock ID Detected");
		}
		clocks[clocks.length] = [clockID, offset];

	}
	function startClocks(){
		intervalID = setInterval(function(){ update(); },200);
	}
	function stopClocks(){
		clearInterval(intervalID);
	}
	function update(){

			var dateNow = new Date();
			se=parseInt(dateNow.getUTCSeconds());
			if (oldS == se) return; //Only update when the seconds have changed
			oldS=se; if (se<10) se="0"+se;

			for (var i = 0; i < clocks.length; i++){
				clockID = clocks[i][0];
				offset = clocks[i][1];
				hh=parseInt(dateNow.getUTCHours() + offset) % 24;   if (hh<10) hh="0"+hh;
				mi=parseInt(dateNow.getUTCMinutes()); if (mi<10) mi="0"+mi;
				document.getElementById(clockID).innerHTML =timeToImage ( hh+":"+mi+":"+se );
			}

	}
	function timeToImage(time){
		s = new String(time);
		imageString = "";
		for (Count = 0; Count < s.length; Count++) {		        
			digit = s.substring (Count, Count+1);
			imageString += "<img src='/images/" + s.substring (Count, Count+1) + ".gif'>";
		}
		return time;
		//return imageString;
	}

	this.update = update;
	this.stopClocks = stopClocks;
	this.startClocks = startClocks;
	this.addClock = addClock;
	this.timeToImage = timeToImage;
}
