/* Sitewide javascript functions */

function equalheight()
{	// will ensure page columns end up equal heights - hard to do without css hacks
	// if javascript not enabled, all that happens is that columns end up unequal - not a disaster!
	// Code assumes #menu will usually be shorter than #main and resizes it if required
	var menu=document.getElementById("menu");
	var main=document.getElementById("main");
	if (menu.offsetHeight<main.offsetHeight) menu.style.height=main.offsetHeight+'px';
}

function realsubmit(me)
{	// ensures that the 'go' field has the correct value when the form is submitted
	// - required because some radio buttons can automatically submit their form
	// and put a standard value into a hidden 'go' field when they do so. This 
	// has to be overridden for the real submit buttons, otherwise the hidden
	// field value can take precedence depending on where the submit button is
	// on the page in relation to the hidden 'go' field.
	myvalue = me.value;
	myform = me.form;
	scanloop:
	for (fn in myform.elements)
	{	f = myform.elements[fn];
		if (f.name == 'go' && f.type == 'hidden')
		{	f.value = myvalue;
			break scanloop;
		}
	}
	myform.submit();
	return true;
}

function hideblock(ctl,id)
{	// Sets element with id to display:none
	if ( ! ctl.checked) return;
	me = document.getElementById(id);
	if (me) me.style.visibility = 'hidden';
}

function showblock(ctl,id)
{	// Sets element with id to display:block
	if ( ! ctl.checked) return;
	me = document.getElementById(id);
	if (me) me.style.visibility = 'visible';
}

