var currentMenu = null; if (!document.getElementById) { document.getElementById = function() { return null; }; } function initializeMenu(menuId, actuatorId) { var menu = document.getElementById(menuId); var actuator = document.getElementById(actuatorId); if (menu == null || actuator == null) return; actuator.onmouseover = function() { if (currentMenu) { if (currentMenu.filters) if (currentMenu.filters[0]) currentMenu.filters[0].Apply(); currentMenu.style.visibility = "hidden"; if (currentMenu.filters) if (currentMenu.filters[0]) currentMenu.filters[0].Play(); } this.showMenu(); a=0; }; actuator.onmouseout = function() { a=1; setTimeout('if(a==1){currentMenu.style.visibility = "hidden"};',100); }; menu.onmouseover = function() { a=0; }; menu.onmouseout = function() { a=1; setTimeout('if(a==1){currentMenu.style.visibility = "hidden"};',100); }; actuator.showMenu = function() { menu.style.left = this.offsetLeft + "px"; menu.style.top = this.offsetTop + this.offsetHeight + "px"; if (menu.filters) if (menu.filters[0]) menu.filters[0].Apply(); menu.style.visibility = "visible"; if (menu.filters) if (menu.filters[0]) menu.filters[0].Play(); currentMenu = menu; }; } function loadMenus() { initializeMenu("aboutMenu", "aboutActuator"); initializeMenu("visitMenu", "visitActuator"); initializeMenu("peopleMenu", "peopleActuator"); initializeMenu("newsMenu", "newsActuator"); initializeMenu("publicationsMenu", "publicationsActuator"); initializeMenu("managingMenu", "managingActuator"); initializeMenu("mapMenu", "mapActuator"); } // AJAX code forking function getHTTPOject() { var xhr = false; if (window.ActiveXObject) { try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { xhr = false; } } } else if (window.XMLHttpRequest) { try { xhr = new XMLHttpRequest(); } catch(e) { xhr = false; } } return xhr; } // AJAX - Grabs a predefined file to pull back into the page function grabFile(file) { var request = getHTTPOject(); if (request) { request.onreadystatechange = function() { displayResponse(request); }; request.open( "GET", file, true ); request.send(null); } } //AJAX - Once the file is found this decides what to do with it. function displayResponse(request) { if (request.readyState == 4) { document.getElementById("mainMenu").innerHTML = request.responseText; loadMenus(); } } // Runs all the listed functions on the loading of the window window.onload=function(){ grabFile("/scripts/mainnav.html"); }