// Autorem skryptu jest: SŁAWOMIR KOKŁOWSKI // www.kurshtml.boo.pl // Jeśli chcesz wykorzystać ten skrypt na swojej stronie, nie usuwaj tego komentarza! // modyfikacje: Piotr Kasprzak function tree(id) { this.id = id; this.click = function () { for (var i = 0, el_node; i < this.parentNode.childNodes.length; i++) { el_node = this.parentNode.childNodes.item(i) if (el_node.nodeName.toLowerCase() == 'ul') { el_node.style.display = el_node.style.display == 'none' ? 'block' : 'none'; this.parentNode.className = (el_node.style.display == 'none' ? 'closed' : 'opened'); return; } } } this.start = function (el) { for (var i = 0, el_node; i < el.childNodes.length; i++) { el_node = el.childNodes.item(i); if (el_node.nodeName.toLowerCase() == 'a') { el_node.onclick = this.click; for (var j = 0; j < el_node.parentNode.childNodes.length; j++) { if (el_node.parentNode.childNodes.item(j).nodeName.toLowerCase() == 'ul') { el_node.parentNode.className = (el_node.className ? el_node.className + ' ' : '') + 'closed'; break; } if (el_node.parentNode.childNodes.item(j).nodeName.toLowerCase() == 'li') break; } if (el_node.href && unescape(el_node.href) == unescape(window.location.href)) { el_node.className = 'active'; var el_parentNode = el_node.parentNode; do { el_parentNode = el_parentNode.parentNode; if (el_parentNode.nodeName.toLowerCase() == 'ul') el_parentNode.style.display = 'block'; if (el_parentNode.nodeName.toLowerCase() == 'li') el_parentNode.className = 'opened'; } while (document.getElementById(this.id) != el_parentNode) } } else if (el_node.nodeName.toLowerCase() == 'ul') { el_node.style.display = 'none'; } this.start(el_node); } } if (document.getElementById && document.childNodes) { this.start(document.getElementById(this.id)); } }