Here's an example of the basics of an implementation that might help you. Note: the output stuff is just for demonstration purposes and not part of the actual solution.
<html>
<head>
<script type="text/javascript">
onload = function()
{
var f = document.forms.test;
f.focusedElem = null;
updateOutput( f );
for ( var i = 0, l = f.elements.length, elem; i < l; i++ )
{
elem = f.elements[i];
elem.onfocus = function( elem )
{
return function()
{
elem.form.focusedElem = elem;
updateOutput( elem.form );
}
}( elem )
elem.onblur = function()
{
f.focusedElem = null;
updateOutput( f )
}
}
}
function updateOutput( f )
{
document.getElementById( 'output' ).innerHTML = ( null == f.focusedElem ) ? 'Nothing!' : f.focusedElem.id;
}
</script>
</head>
<body>
<form name="test">
<input type="checkbox" name="foo" id="foo1">
<input type="checkbox" name="foo" id="foo2">
<input type="checkbox" name="foo" id="foo3">
<input type="checkbox" name="foo" id="foo4">
</form>
What has focus? <span id="output"></span>
</body>
</html>