var inmenu=false;
var lastmenu=0;
function findPosX(obj) {
	var curleft = 0;
	if(obj.offsetParent)
		while(1) 
		{
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj) {
	var curtop = 0;
	if(obj.offsetParent)
		while(1) 
		{
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}
function utilMenu(current) {
   if (!document.getElementById) return;
   inmenu=true;
   oldmenu=lastmenu;
   lastmenu=current;
   if (oldmenu) Erase(oldmenu);
   //This will hide the main navigation
   var mainNav = document.getElementById('rollover').childNodes;
   for (var i=0;i<mainNav.length;i++) {
		if (mainNav[i].tagName == "LI") {
			mainNav[i].className = "rolloverLink";			
		}
   }
   //
   m=document.getElementById("menu-" + current);
   box=document.getElementById(current);
      if (box.className == "subnav_drop") {
   		m.style.backgroundColor="#0080CC";
   		m.style.color="#FFFFFF";
   		xPos = findPosX(m);
   		yPos = findPosY(m) + m.offsetHeight;
   } else {
   		m.style.backgroundColor="#5A008C";
   		xPos = m.offsetLeft + document.getElementById("nav").offsetLeft;
		if (document.all) {
			xPos += 40;  //quick fix for IE horiz positioning
		}
   		yPos = m.offsetBottom;
   }
	box.style.visibility="visible";
	box.style.left = xPos+"px";
	box.style.top = yPos+"px";
	var anchor =  m.getElementsByTagName("a")[0];
	anchor.className = "change";
}
function Erase(current) {
   if (!document.getElementById) return;
   if (inmenu && lastmenu==current) {
     return;
   }
   m=document.getElementById("menu-" + current);
   box=document.getElementById(current);
   if (box.className == "subnav_drop") {
   		m.style.backgroundColor="#FFFFFF";
   		m.style.color="#0080CC";
   } else {
   		m.style.backgroundColor="#410066";
   }
   box.style.visibility="hidden";
   var anchor =  m.getElementsByTagName("a")[0];
	anchor.className = "";
}
function Timeout(current) {
   inmenu=false;
    window.setTimeout("Erase('" + current + "')",800);
}
function openReg(filename,width,height) {
	window.open(filename,'demowindow','width='+width+',height='+height+',resizable=1,scrollbars=1');
}
