/*=====================================================================*
|| ###################################################################
|| # Blue Static ISSO Framework
|| # Copyright (c)2005-2008 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version 2 of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/
function nav_init(openSectionID, selectedItemID)
{
var nav = document.getElementById("nav");
var openSection = document.getElementById(_name(openSectionID));
var selectedItem = document.getElementById(_name(selectedItemID));
// open the proper nav section
if (openSection)
{
openSection.className = "expand";
_adjacent_ul(openSection).style.display = "block";
}
// bold the selected link
if (selectedItem)
selectedItem.className = "selected";
// register the nav sections
var sections = nav.getElementsByTagName("ul");
sections = sections[0].childNodes;
for (var i = 0; i < sections.length; i++)
{
// grab only <li> elements that do not have an <ul> in them
if (sections[i].nodeName.toLowerCase() == "li" && sections[i].childNodes.length == 1)
sections[i].onclick = nav_toggle;
}
}
function nav_toggle()
{
// we have a class name, so we need to hide
if (this.className)
{
this.className = "";
_adjacent_ul(this).style.display = "none";
}
// show the block
else
{
this.className = "expand";
_adjacent_ul(this).style.display = "block";
}
}
function _name(str)
{
return "nav_" + str;
}
function _adjacent_ul(elm)
{
// <li> + #text + <li> > #text == <ul>
return elm.nextSibling.nextSibling.firstChild.nextSibling;
}