/* Binary clock
 * Shows the time in binary form
 * (c) djgdesign
 * If you wish to use this script, please give djgdesign credit
 * and use the email form to contact me (I would be interested to see how it is implemented)
 */
 
function clockTick()
{
	//Change the 'clock' to the ID of the container to put the binary clock in
	setInterval("showClock('clock')",1000);
}

function showClock(containerID)
{
	//Editable variables
	var highlight = "#3399ff";
	var lowlight = "#666666";
	
	//Do not change
	var container = document.getElementById(containerID);
	var today = new Date();
	
	var second = today.getSeconds() + "";
	var second1;
	var second2;
	
	if(second.length == 2) 
	{
		second1 = second.substr(0,1);
		second2 = second.substr(1,1);
	}
	else
	{
		second1 = 0;
		second2 = second;
	}
	
	var minute = today.getMinutes()+ "";
	var minute1;
	var minute2;
	
	if(minute.length == 2)
	{
		minute1 = minute.substr(0,1);
		minute2 = minute.substr(1,1);
	}
	else
	{
		minute1 = 0;
		minute2 = minute;
	}
	
	var hour = today.getHours() + "";
	var hour1;
	var hour2;
	
	if(hour.length == 2)
	{
		hour1 = hour.substr(0,1);
		hour2 = hour.substr(1,1);
	}
	else
	{
		hour1 = 0;
		hour2 = hour;
	}
	
	//Do actual colouring of the binary dots
	//Set the styles of the container
	container.style.lineHeight = "50%";
	container.style.color = lowlight;
	
	//Top line				
	container.innerHTML = "&bull;&nbsp;";
	if (hour2 == 8 || hour2 == 9)
	{
		container.innerHTML += "<span style=\"color:" + highlight +"\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	container.innerHTML += "&bull;&nbsp;";
	if (minute2 == 8 || minute2 == 9)
	{
		container.innerHTML += "<span style=\"color: " + highlight +";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	container.innerHTML += "&bull;&nbsp;";
	if (second2 == 8 || second2 == 9)
	{
		container.innerHTML += "<span style=\"color: " + highlight + ";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	
	//Second line down			
	container.innerHTML += "<br />";
	container.innerHTML += "&bull;&nbsp;";
	if (hour2 == 7 || hour2 == 6 || hour2 == 5 || hour2 == 4)
	{
		container.innerHTML += "<span style=\"color:" + highlight +"\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (minute1 == 7 || minute1 == 6 || minute1 == 5 || minute1 == 4)
	{
		container.innerHTML += "<span style=\"color: " + highlight +";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (minute2 == 7 || minute2 == 6 || minute2 == 5 || minute2 == 4)
	{
		container.innerHTML += "<span style=\"color: " + highlight +";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (second1 == 7 || second1 == 6 || second1 == 5 || second1 == 4)
	{
		container.innerHTML += "<span style=\"color: " + highlight + ";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (second2 == 7 || second2 == 6 || second2 == 5 || second2 == 4)
	{
		container.innerHTML += "<span style=\"color: " + highlight + ";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	
	//Third line down			
	container.innerHTML += "<br />";
	if (hour1 == 7 || hour1 == 6 || hour1 == 3 || hour1 == 2)
	{
		container.innerHTML += "<span style=\"color:" + highlight +"\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (hour2 == 7 || hour2 == 6 || hour2 == 3 || hour2 == 2)
	{
		container.innerHTML += "<span style=\"color:" + highlight +"\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (minute1 == 7 || minute1 == 6 || minute1 == 3 || minute1 == 2)
	{
		container.innerHTML += "<span style=\"color: " + highlight +";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (minute2 == 7 || minute2 == 6 || minute2 == 3 || minute2 == 2)
	{
		container.innerHTML += "<span style=\"color: " + highlight +";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (second1 == 7 || second1 == 6 || second1 == 3 || second1 == 2)
	{
		container.innerHTML += "<span style=\"color: " + highlight + ";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (second2 == 7 || second2 == 6 || second2 == 3 || second2 == 2)
	{
		container.innerHTML += "<span style=\"color: " + highlight + ";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	
	//Last line
	container.innerHTML += "<br />";
	if (hour1 == 9 || hour1 == 7 || hour1 == 5 || hour1 == 3 || hour1 == 1)
	{
		container.innerHTML += "<span style=\"color:" + highlight +"\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (hour2 == 9 || hour2 == 7 || hour2 == 5 || hour2 == 3 || hour2 == 1)
	{
		container.innerHTML += "<span style=\"color:" + highlight +"\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (minute1 == 9 || minute1 == 7 || minute1 == 5 || minute1 == 3 || minute1 == 1)
	{
		container.innerHTML += "<span style=\"color: " + highlight +";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (minute2 == 9 || minute2 == 7 || minute2 == 5 || minute2 == 3 || minute2 == 1)
	{
		container.innerHTML += "<span style=\"color: " + highlight +";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (second1 == 9 || second1 == 7 || second1 == 5 || second1 == 3 || second1 == 1)
	{
		container.innerHTML += "<span style=\"color: " + highlight + ";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
	if (second2 == 9 || second2 == 7 || second2 == 5 || second2 == 3 || second2 == 1)
	{
		container.innerHTML += "<span style=\"color: " + highlight + ";\">&bull;</span>&nbsp;";
	}
	else
	{
		container.innerHTML += "&bull;&nbsp;";					
	}
}