document.onclick = mouseClick;

function mouseClick(e){
	e = e || window.event;
	
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	//do more
	if (targ.name!='answers[]' && targ.name!='spellings[]' && targ.name!='ch') hidecontrol();	
}

function sure ()
{
	if (confirm('Are you sure?'))
		return true;
	else
		return false;
}

function insertchar(letter, place)
{
	
	var box = document.getElementById(place);
	box.value = (box.value)+letter;
	box.focus();
}

function hidecontrol()
{
	//hide all insert controls
		
	for (var i=1; i<=20; i++)
	{
		box = document.getElementById('b'+i);
		box.style.display = '';
	}
	for (var i=1; i<=20; i++)
	{
		box = document.getElementById('c'+i);
		box.style.display = '';
	}
}

function showcontrol(valueid)
{
	//hide all insert controls
	for (var i=1; i<=20; i++)
	{
		box = document.getElementById('c'+i);
		box.style.display = '';
	}
	for (var i=1; i<=20; i++)
	{
		box = document.getElementById('b'+i);
		box.style.display = '';
	}	
	
	var control = document.getElementById(valueid);
	control.style.display = 'block';
}