function getElementsByClassName(className, tag, elm){
    var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)")
    var tag = tag || "*"
    var elm = elm || document
    var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag)
    var returnElements = []
    var current
    var length = elements.length
    for(var i=0; i<length; i++){
        current = elements[i]
        if(testClass.test(current.className)){
            returnElements.push(current)
        }
    }

    return returnElements;
}

// init fold/unfold menu
function init_navigation() {
    // collect navigation items 
    var items = getElementsByClassName("navigation_item", "li")

    // loop through items and set the mouseover and mouseout
    // functionality on each item, and also on the target
    // child elements (this to stop the menu from collapsing
    // on title mouseout)
    var current
    for(i = 0; i < items.length; i++) {
        current = items[i]
        // set mouseover functionality
        current.onmouseover = function () {
            var children = this.childNodes
            // loop through children
            for(j = 0; j < children.length; j++) {
                var child = children[j]
                // if this child is a <ul> element,
                // show it, and bind functionality
                if(child.tagName == "UL") {
                    child.style.display = "block"
                    child.onmouseover = function () {
                        this.style.display = "block"
                    }
                    child.onmouseout  = function () {
                        this.style.display = "none"
                    }
                }
            }
        }

        current.onmouseout  = function () {
            var children = this.childNodes
            for(j = 0; j < children.length; j++) {
                var child = children[j]
                if(child.tagName == "UL")
                    child.style.display = "none"
            }
        }
    }
}