/** * landgate_dynamic.js * * JavaScript functions for Landgate corporate website pages requiring dynamic * expansion and contraction (display and undisplay) of page elements. */ /** * Determine whether the specified item is open. * @param elem DOM element to test. * @return True if the item is open, or false if it is closed. */ function isItemOpen(elem) { if (elem !== null && typeof(elem) !== 'undefined') { return elem.style.display === 'block'; } else { return false; } } /** * Open the specified item. * @param elem DOM element to manipulate. */ function openItem(elem) { if (elem !== null && typeof(elem) !== 'undefined') { elem.style.display = 'block'; } } /** * Open all items of the specified element type (tag name) and class. * * @param className Value to look for in the class attribute. * @param tagName Name of the tags to manipulate. Defaults to 'div'. */ function openAllItems(className, tagName) { if (!tagName) { tagName = 'div'; } var ar = document.getElementsByTagName(tagName); for (var i=0; i= 0 && index == href.length - sectionEntryUrl.length) { mainNavLinks[i].className = 'selected'; } } // Highlight the currently selected link in side navigation. var sideNav = document.getElementById('sideNav'); var sideNavLinks = sideNav.getElementsByTagName('a'); for (var j=0; j= 0 && index == currentPageUrl.length - href.length) { sideNavLinks[j].className = 'selected'; } } } /** * Show the selected submenu and the current section submenu, hiding all others. */ function switchSubMenu(menuID, currentSectionMenuID, className) { closeAllItems(className); openItem(document.getElementById(menuID)); openItem(document.getElementById(currentSectionMenuID)); } /** * Show the current section submenu only, hiding all others. */ function resetMenu(currentSectionMenuID, className) { closeAllItems(className); if (currentSectionMenuID !== '') { openItem(document.getElementById(currentSectionMenuID)); } } /** * Call this method to prevent propagation of the event e in a cross-browser * manner. * * @param e Event to block. For IE, this will be ignored and window.event * will be used instead. */ function blockEvent(e) { if (!e) var e = window.event; e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); }