// JavaScript Document
function updateBcSet(group, time) {
	var t2 = time%10;
	var t1 = (time-t2)/10;
	for(var x=8; x>0; x=x/2) {
		if( (t1 - x) >= 0 ) {$("#"+group+"a"+x).attr("class","cell on"); t1-=x; }
		if( (t2 - x) >= 0 ) {$("#"+group+"b"+x).attr("class","cell on"); t2-=x; }
	}
}

function updateBinaryClock() {
	var today=new Date();
	$("#binaryClockContainer div.cell").attr("class","cell off");
	updateBcSet("s",today.getSeconds());
	updateBcSet("m",today.getMinutes());
	updateBcSet("h",today.getHours());
	var titleHours = today.getHours();
	var titleMinutes = today.getMinutes();
	var titleSeconds = today.getSeconds();
	var titleTime = titleHours + ":" + titleMinutes + ":" + titleSeconds;
	$("#binaryClockContainer").attr("title",titleTime);
	setTimeout('updateBinaryClock()',1000);
}
