var iPath = "/online/ee/inet.nsf/"; // Script runs when page is loaded, marks the selelected DIV-ID if present in HREF ("&markID=") function MarkSelected() { var arrHref; var arrHref2; var arrObjects; var strGeneralname; var oLev1; var oLev2; var oLev3; arrHref = document.location.href.split("markID="); // Does markID exist in href? if (typeof(arrHref[1]) === 'string') { arrHref2 = arrHref[1].split("&"); // Split the string making objects out of IDs arrObjects = arrHref2[0].split("-"); if (arrObjects.length >= 0) oLev1 = document.getElementById(arrObjects[0]); if (arrObjects.length >= 1) oLev2 = document.getElementById(arrObjects[0] + '-' + arrObjects[1]); if (arrObjects.length >= 2) oLev3 = document.getElementById(arrObjects[0] + '-' + arrObjects[1] + '-' + arrObjects[2]); // Find the selected ID oSelected = document.getElementById(arrHref2[0]); // Does mark-ID exist? if (oSelected != null) { // Make sure this is a correct element before we move on if (oSelected.parentNode.tagName === 'LI' && oSelected.tagName === 'A'){ // Make background coloured oSelected.className = 'selbg'; // 1st lvl, mark the underlaying UL if exists if (oLev1 != null && oLev1.nextSibling != null && oLev1.nextSibling.nextSibling != null && oLev1.nextSibling.nextSibling.tagName === 'UL'){ oLev1.nextSibling.nextSibling.className = 'sel'; if (oSelected.id === oLev1.id){ oLev1.className = 'sel selbg'; }else{ oLev1.className = 'sel'; } } // 2nd level, mark the underlaying UL if exists if (oLev2 != null && oLev2.nextSibling != null && oLev2.nextSibling.nextSibling != null && oLev2.nextSibling.nextSibling.tagName === 'UL'){ oLev2.nextSibling.nextSibling.className = 'sel'; oLev2.className = 'sel'; } // 3rd lvl, mark the underlaying UL if exists if (oLev3 != null && oLev1.nextSibling != null && oLev1.nextSibling.nextSibling != null && oLev1.nextSibling.nextSibling.tagName === 'UL'){ oLev1.className = 'sel'; } } } } } function mloader(){ oElement = document.getElementById("leftmenu"); // Does element exist? if (oElement != null){ arrAtags = oElement.getElementsByTagName("a"); for (var a=0; a < arrAtags.length; a++){ addEvent(arrAtags[a],"click",mfunc,false); } } // Run markid check. MarkSelected(); } // Executes onclick in menu function mfunc(evt){ oElement = findOwner(evt); // Get submenu-object (UL) if (oElement != null && oElement.nextSibling != null && oElement.nextSibling.nextSibling != null && oElement.nextSibling.nextSibling.nodeName === 'UL'){ oElementUL = oElement.nextSibling.nextSibling; }else{ // No submenu, quit event and let a-href run return true; } // Does elements exist? if (oElement != null){ strClassStatus = oElement.className; if(oElement.className == "sel" || oElement.className == "sel selbg"){ oElement.className = ""; }else{ oElement.className = "sel"; } oElementUL.className = oElementUL.className == "sel" ? "":"sel"; // Does sURL contain "reload=1"? rExp = /reload\=1/gi; strResults = oElement.href.search(rExp) // If reload=1 then let a-href run, but ONLY if you aren't already on this page. Then cancel this check. arrHref = document.location.href.split("markID="); if (typeof(arrHref[1]) === 'string'){ arrHref2 = arrHref[1].split("&"); strCheck = arrHref2[0]; }else{ strCheck = ''; } // DOM style return false AND IE style return false (only if href doesn't contain reload=1 and you are not currently on this page) if (oElement.parentNode.parentNode.id === 'leftmenu' && strResults != -1 && strClassStatus != 'sel selbg' && strCheck != oElement.id){ return true; }else{ if (evt && evt.preventDefault){ evt.preventDefault(); } return false; } }else{ // Can't find elements quit gracefully return true; } } // Adds custom events to objects function addEvent(obj, evType, fn, useCapture){ if (obj.addEventListener && 1 === 0){ obj.addEventListener(evType, fn, useCapture); return true; }else if (obj.attachEvent && 1 === 0){ var r = obj.attachEvent("on"+evType, fn); return r; }else{ // Try adding the old way obj.onclick = mfunc; return true; } } // Finds the onclick-events owner-object (A-tag) function findOwner(evt){ var node; if (document.all){ node = window.event.srcElement; while (node){ if (node.tagName == "A"){ return node; } node = node.parentElement; } }else{ node = evt.target; while (node){ if (node.nodeType == Node.ELEMENT_NODE && node.nodeName == "A"){ return node; } node = node.parentNode; } } return null; }