// Test if the specified key press (in event) is in the specified match string
// Usage: return onkeypress="return keypressInRange(event, '0123456789.-');"
function keypressInRange(evt, match)
{
	evt = (evt)? evt : event;
	var charCode = (evt.charCode)? evt.charCode : ((evt.keyCode)? evt.keyCode : ((evt.which)? evt.which : 0));
	return (charCode <= 31 || match.indexOf(String.fromCharCode(charCode)) != -1);
}

function CBool(vValue, attributeName) {
	var v = vValue.toString().toLowerCase(); return (v=='1' || v==attributeName || v=='true')
}
function elementContainedIn(container, element) {
	while (element) {
		if (element == container) return true;
		element = element.parentElement;
	}
	return false;
}
function CancelEvent() { event.returnValue = false;event.cancleBubble = true;return false; }
function flipVisibility (e) { e.style.display = e.style.display == 'none' ? '' : 'none'; }

function minMax(obj, img) 
{
	if(obj != null)
	{
		if (obj.style.display=="none") 
		{
			obj.style.display="block";
			img.src=img.src.replace('iconClosed.gif', 'iconOpen.gif');
			if (document.all('__XPORTALEXPANDEDGRPS') != null) {
				document.all('__XPORTALEXPANDEDGRPS').value += ';' + obj.id + ';';
			}
		} 
		else 
		{
			obj.style.display="none";
			img.src=img.src.replace('iconOpen.gif', 'iconClosed.gif');
			if (document.all('__XPORTALEXPANDEDGRPS') != null) {
				document.all('__XPORTALEXPANDEDGRPS').value = document.all('__XPORTALEXPANDEDGRPS').value.replace(';' + obj.id + ';', '');
			}
		}
	}
}