function openmbwin(inURL, inW, inH, inOn, inName) {
	var thefeatures;
	if (inName == "random" || inName == null) inName = "win" + Math.round(Math.random()*1000);
	if (inW == 0) inW = 600;
	if (inH == 0) inH = 500;
	if (inOn == null) inOn = 1;
	if (inOn == 1) {
		thefeatures = "scrollbars,menubar,toolbar,location,status,resizable,width=" + inW +",height=" + inH;
	} else {
		thefeatures = "scrollbars,resizable,width=" + inW +",height=" + inH;
	}
	var mwin = window.open(inURL,inName,thefeatures);
	if (mwin != null) {
		mwin.focus();
	}
}

// popupmenu
var innav = 0;
var vcurrentmenu = null;

function showpumenu(inobjid,inid,inrendertype,e) {
	myaboid = inobjid;
	myvid = inid;
	myaborendertype = inrendertype;
	if (document.getElementById) {
		var thenav = document.getElementById("pumenu");
		if (vcurrentmenu != null) {
			hidenav();
		}
		vcurrentmenu = thenav;
		//alert("E:" + e);
		if (!e) { 
			var e = window.event;
		}
		if (e.pageX || e.pageY) {
			x = e.pageX;
			y = e.pageY;
		} else {
			x = e.x + document.body.scrollLeft;
			y = e.y + document.body.scrollTop;
			if (document.documentElement.scrollLeft) {
				x += document.documentElement.scrollLeft;
			}
			if (document.documentElement.scrollTop) {
				y += document.documentElement.scrollTop;
			}
		}
		e.cancelBubble = true;
		
		// new to set popup text
		var thehltext = document.getElementById("puhighlight");
		if (myhighlights[inobjid]) {
			if (myhighlights[inobjid] == 1) {
				thehltext.innerHTML = "remove highlight";
			} else {
				thehltext.innerHTML = "add highlight";
			}
		} else {
			thehltext.innerHTML = "add highlight";
		}
		// end new
		
		thenav.style.left = x + "px"; // adding 10 since IE ignores the margin
		thenav.style.top = y + "px"; // adding 10 since IE ignores the margin
		thenav.style.visibility = "visible";
	}
}

function showmbmenu(inmenu,e) {
	if (document.getElementById) {
		var thenav = document.getElementById(inmenu);
		var themb = document.getElementById(inmenu + "head");
		if (vcurrentmenu != null) {
			hidenav();
		}
		vcurrentmenu = thenav;
		if (themb.offsetTop) {
			x =  themb.offsetLeft;
			y =  themb.offsetTop;
			y += 14;
		}
		var thembparent = themb.offsetParent;
		while(thembparent) {
			y += thembparent.offsetTop;
			thembparent = thembparent.offsetParent;
		}
		thenav.style.left = x + "px"; 
		thenav.style.top = y + "px"; 
		thenav.style.visibility = "visible";
	}
}

function hidenav() {
	if (document.getElementById) {
		vcurrentmenu.style.visibility = "hidden";
		vcurrentmenu = null;
	}
}

function additemhandler(inid) {
	if (document.getElementById) {
		var thediv = document.getElementById(inid);
		if (document.addEventListener) {
			thediv.addEventListener("mouseover",thedivoverhandler,false);
		} else {
		
			document.onmouseover = function() {
				if (innav == 1) {
					innav=0;
					hidenav();
				}
			};
			thediv.onmouseover = function() {
				innav = 1;
				var e = window.event;
				e.cancelBubble = true;
			};
		}
		
	}
}

function adddochandler() {
	if (document.getElementById) {
		if (!document.addEventListener) {
		
			document.onmouseover = function() {
				if (innav == 1) {
					innav=0;
					hidenav();
				}
			};
			
		}
		
	}
}

function overhandler(e) {
	if (e.eventPhase >= 2) {
		if ((innav == 1) && (vcurrentmenu != null)) {
			innav = 0;
			vcurrentmenu.style.visibility = "hidden";
			vcurrentmenu = null;
			document.removeEventListener("mouseover",overhandler,false);
		}
	}
}

function thedivoverhandler(e) {
	innav = 1;
	e.stopPropagation();
	document.addEventListener("mouseover",overhandler,false);
}


function addhandlers() {
	adddochandler();
	additemhandler('contentsmenu');
	additemhandler('practicemenu');
	additemhandler('coursemenu');
	additemhandler('personalmenu');
	additemhandler('resourcesmenu');
	additemhandler('hlmenu');
	additemhandler('helpmenu');
}
