
var ActiveNavMenu = 0;
var tid = null;

function initDropMenu (ndm) {

  popupmessage();
//  document.onclick = hideDropMenu;
  numDropMenu = ndm;
  for (i=1; i<=numDropMenu; i++) {
    navName = 'navmenu' + i;
    dropName = 'dropMenu' + i;
    document.getElementById(navName).onmouseout   = menuOut;
    document.getElementById(navName).onclick      = showDropMenu;
    document.getElementById(navName).onmouseover  = showDropMenu;
    document.getElementById(dropName).onmouseout  = menuOut;
    document.getElementById(dropName).onmouseover = showDropMenu;
    }
    return;
}

function menuOut(e) {

    tid = setTimeout ( "hideDropMenu()",5 );

}

function showDropMenu(e) {

     if (tid) {
        clearTimeout ( tid );
        }

     var menuID = this.id.substr(this.id.length - 1, this.id.length);

     if (ActiveNavMenu != menuID) {

	if (ActiveNavMenu != 0) {
           hideDropMenu();
        }

        dropMenuName = 'dropMenu' + menuID;

        var leftC = topC = 0;

	leftC = this.offsetLeft + this.offsetParent.offsetLeft;
	topC  = this.offsetTop  + this.offsetParent.offsetTop + this.offsetParent.offsetHeight;

        document.getElementById(dropMenuName).style.left = leftC + 'px';
        document.getElementById(dropMenuName).style.top  = topC + 'px';
        document.getElementById(dropMenuName).style.visibility = 'visible';
	         
        ActiveNavMenu = menuID;
     }
}

function hideDropMenu() {

     dropMenuName = 'dropMenu' + ActiveNavMenu;
     document.getElementById(dropMenuName).style.visibility = 'hidden';

     ActiveNavMenu = 0;
}

function showPopup(url) {
	
	newwindow=window.open(url,'name','height=400,width=520,top=200,left=300,resizable=yes,scrollbars=yes,titlebar=no,statusbar=no,location=no');
	if (window.focus) {
	   newwindow.focus();
	}
} 