if (typeof CunninghamLindsey == "undefined") { CunninghamLindsey = {}; } CunninghamLindsey.SectionMenu = function() { var m_objActive = null; return { init: function(obj) { var r; var li; var a; var aChevron, img; r = document.getElementById(obj.root); if (!r) { return; } if (r.getElementsByTagName("ul").length == 0) { return; } r = r.getElementsByTagName("ul")[0]; // traverse the direct child nodes to find the top level LIs for (li = r.firstChild; li != null; li = li.nextSibling) { if (li.tagName.toLowerCase() == "li") { // has child nodes if (li.className == "on" || li.className == "on open") { aChevron = document.createElement("a"); img = document.createElement("img"); aChevron.className = "chevron"; img.src = obj.chevron; aChevron.appendChild(img); a = li.getElementsByTagName("a")[0]; aChevron.__obj = { href: a.href, parent: li }; aChevron.onclick = function() { CunninghamLindsey.SectionMenu.click(this); }; aChevron.href = "javascript:void(0)"; if (li.className == "on") { li.className = "off activated"; } if (li.className == "on open") { li.className = "on activated"; } li.insertBefore(aChevron, a); } } } }, click: function(callee) { if (m_objActive != null) { if (m_objActive != callee.__obj.parent) { m_objActive.className = "off activated"; } } m_objActive = callee.__obj.parent; if (callee.__obj.parent.className == "on activated") { callee.__obj.parent.className = "off activated"; return; } if (callee.__obj.parent.className == "off activated") { callee.__obj.parent.className = "on activated"; } } }; } ();