var ie5 = document.all && !window.opera
var ns6 = document.getElementById

function iecompattest() {
	return (document.compatMode && document.compatMode.indexOf("CSS") != -1) ? document.documentElement : document.body
}

function showmenu(e, text, obj, action, href) {
	if (!document.all && !document.getElementById)
		return
	clearhidemenu();
	var url_company;
	var company_text;
	menuobj = ie5 ? document.all.popitmenu : document.getElementById("popitmenu");
	if (action == "view") {
		url_company = href;
		company_text = "View the " + text + " record";
	}
	else {
		url_company = "search.php?keywords=" + text;
		company_text = "Search for " + text + " as a company";
	}
	
	var url_news = "topics.php?keywords=" + text;
	var url_people = "people.php?contactName=" + text;
	var company = "<tr><td><a style='padding:5px;' href='" + url_company + "'><img border='0' style='margin-right:5px;' src='images/ico_table.png'>" + company_text + "</a></td></tr>";
	var news = "<tr><td><a style='padding:5px;' href='" + url_news + "'><img border='0' style='margin-right:5px;' src='images/ico_magnifier.png'>Search for " + text + " in the news</a></td></tr>";
	var people = "<tr><td><a style='padding:5px;' href='" + url_people + "'><img border='0' style='margin-right:5px;' src='images/ico_group.png'>Search for people called " + text + "</a></td></tr>";
	menuobj.innerHTML = "<table> " + company + news + people + "</table>";
		
	var osL = 0;
	var osT = 0;
	var h = obj.offsetHeight;
	if(obj.offsetParent) {
		while(obj) {
			osL += obj.offsetLeft;
			osT += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}

	menuobj.style.left = osL;
	menuobj.style.top = osT + h;
	menuobj.style.visibility = "visible"
	return false
}

function contains_ns6(a, b) {
	while (b.parentNode)
		if ((b = b.parentNode) == a)
		return true;
	return false;
}

function hidemenu() {
	if (window.menuobj)
		menuobj.style.visibility = "hidden"
}

function dynamichide(e) {
	if (ie5 && !menuobj.contains(e.toElement))
		hidemenu()
	else if (ns6 && e.currentTarget != e.relatedTarget && !contains_ns6(e.currentTarget, e.relatedTarget))
		hidemenu()
}

function delayhidemenu() {
	delayhide = setTimeout("hidemenu()", 100)
}

function clearhidemenu() {
	if (window.delayhide)
		clearTimeout(delayhide)
}