function hideOnClick(id1, id2) {

	if (document.addEventListener){
	  document.addEventListener('click', function() { hideOnCall(id1, id2); }, false); 
	} else if (document.attachEvent){
	  document.attachEvent('onclick', function() { hideOnCall(id1, id2); });
	}
	
	//window.removeEventListener('click',hideOnCall,false);
}

//window.onload=function(){
//document.onclick = function() {
//		if (!document.getElementById('institutions_input').onclick) { 
//		alert('institutions_input clicked'); 
//	}
//	}
//}

var clickedElements = '';
function hideOnCall(id1, id2) {
	//x=event.clientX;
	//y=event.clientY;
	//divTop = document.getElementById('institutions_tip').style.top;
	//divLeft = document.getElementById('institutions_tip').style.left;
	//divBottom = document.getElementById('institutions_tip').style.bottom;
	//divRight = document.getElementById('institutions_tip').style.right;
	//alert("X coords: " + x + ", Y coords: " + y + ", divTop" + divTop + ", divLeft" + divLeft + ", divBottom" + divBottom + ", divRight" +divRight);
	//add listener
	elements = document.getElementsByTagName('*');
	for(i=0; i<elements.length; i++)
	{
		if (!elements[i].onclick) { // if element doesn't have an onclick handler 
			elements[i].onclick = function() {
									clickedElements += '_' + this.id;
								  } 
		}
	  //new Function('hideDivNow("' + elements[i].id +'");');
	} 
	//if(clickedElements.indexOf('institutions_input') == -1) { hideDiv('institutions_tip'); }
	if(clickedElements.indexOf(id1) == -1) { hideDiv(id2); }
	clickedElements = '';
	//window.addEventListener('click',hideDivNow,true);
	//window.addEventListener('click',function () { },true);
	//window.onclick = hideDivNow;
	//window.captureEvents(Event.CLICK);
	//window.onclick= hideDivNow;
	//window.releaseEvents(Event.CLICK);
}

function getOs(theThing) {
	var osL = 0;
	var osT = 0;
	var msg = '';
	var i = 0;
	if ((theThing.offsetLeft && theThing.offsetTop) ||
	(document.body.offsetLeft && document.body.offsetTop)) {
	while (theThing.parentNode) {
	++i;
	msg += '\n' + i + ': '
	+ theThing.parentNode
	+ ' offsetLeft: '
	+ theThing.offsetLeft
	+ ' offsetTop: '
	+ theThing.offsetTop;
	osL += +theThing.offsetLeft;
	osT += +theThing.offsetTop;
	theThing = theThing.parentNode;
	}
	alert('Totals: offsetLeft = ' + osL
	+ ' & offsetTop = ' + osT
	+ '\n' + msg);
	} else {
	alert('Ooops, offsetLeft && offsetTop not supported with '
	+ theThing.nodeName + ' in '
	+ navigator.appName + ' : '
	+ navigator.appVersion);
	}
}
