/*Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
    var i;
    for (i=0; i < this.length; i++) {
        // Matches identical (===), not just similar (==).
        if (this[i] === value) {
            return true;
        }
    }
    return false;
};*/

function inArray(array, value)
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
    var i;
    for (i=0; i < array.length; i++) {
        // Matches identical (===), not just similar (==).
        if (array[i] === value) {
            return true;
        }
    }
    return false;
};

function toggleDown(nav, activeString) {
    var navroot = document.getElementById(nav);
    var lis = navroot.getElementsByTagName("UL");
    
    var activeArray = activeString.split('|');
    
    for (i=0; i<lis.length; i++) {
        //var b = activeString.search("/\|"+lis[i].id+"\|/");
        //var b = activeString.match("|"+lis[i].id+"|");
        //window.alert('|'+lis[i].id+'|' + ' v ' + activeString + ' na ' + b + ' pozici');
        if(!inArray(activeArray, lis[i].id.substring(1))) {
            lis[i].style.display='none';
        }            
    }
    
    for (i=0; i<activeArray.length; i++) {
        var sw 
        if(sw = document.getElementById('t'+activeArray[i])) {
            sw.className = 'toggle_open';
        }
    }
    //window.alert(activeString);
}

function toggle(kat) {
    var submenu;
    if(submenu = document.getElementById('m'+kat)) {
        var visible = (submenu.style.display != 'none');
        if(visible) {
            submenu.style.display='none';
            document.getElementById('t'+kat).className = 'toggle_close';
        } else {
            submenu.style.display='block';
            document.getElementById('t'+kat).className = 'toggle_open';
        }
    }
    
    return false;
}
