/* toggleci - show or unshow element(arg) */
function toggleci(el) 
{
	if (el.style.visibility == 'hidden') {
		el.style.visibility = '';
		el.style.display = 'block';
	} else {	
		el.style.visibility = 'hidden';
		el.style.display = 'none';
	}
}

/* hideci - hide ALL category items */
function hideci()
{
    var lis = document.getElementsByTagName("li");
    for (var i=0; i<lis.length; i++) 
    {
        var li = lis[i];
        if (li.className == "ci") {
            toggleci(li);
        }
    } 
}

/* getcat - get parent item */
function getcat(e) {
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
    var targ;
    if (!e) {
        var e=window.event;
    }
    if (e.target) {
        targ=e.target;
    } else if (e.srcElement) {
        targ=e.srcElement;
    }
    if (targ.nodeType==3)
    { // defeat Safari bug
        targ = targ.parentNode;
    }
    return targ;
}

/* followlink - finds an anchor in the listitem and follows it */
function followlink(e){
    var targ = getcat(e);
    if (targ.tagName == 'LI' ){
        targ = targ.parentNode;
    }
    /* if ( targ.tagName == 'UL') { */
    var href = targ.getElementsByTagName("a")[0];
    window.location = href;
    /*}*/
}

/* togglecat - show or hide this category's items */
function togglecat(e){
    for (   var targ = getcat(e); 
            targ.className != "clisti"; 
            targ = targ.parentNode);
    // ie6/7 heeft blijkbaar een andere index nodig 
    //targ = targ.childNodes[1];
    targ = targ.getElementsByTagName("ul")[0];
    var nodes = targ.childNodes;
    var el,j;
    for (var i=0; i<nodes.length; i++) 
    {
        n = nodes[i];
        /*if (n.className == "ci") {*/
        if (n.className != "clisth" && n.tagName =="LI") {
             toggleci(n);
        }
        if (n.className == "clisth") {
            var v;
            /* more ugly js hacks,to get the current imagename */
            if(n.currentStyle) { /* IE Opera*/ 
                v = n.currentStyle.backgroundImage;
            } else { /* Firefox */ 
                v = getComputedStyle(n,'').getPropertyValue('background-image');
            } 
            /* toggle background image */
            if (v.substring(v.length - 9 ,v.length-1) == 'plus.png') {
                n.style.backgroundImage = "url('css/minus.png')";
            }else{
                n.style.backgroundImage = "url('css/plus.png')";
            }
        }
    } 
}

