<!--
/*sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className += " sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className = this.className.replace(new RegExp("\\s?sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);*/

var activeNavigationItem = null;
var arrows = null;

$(document).ready(function() {
    //extend the navigation with jquery mouse leave handlers
    $('#nav').mouseleave(closeSubnav);
    //remove mouseover and out for touch devices
    if (window.Touch) {
        $('body').css('background-image', "none");
        $('.navblock').removeAttr("onmouseover");
        $('.navblock').removeAttr("onmouseout");
        //fix the member flag not showing up on ipad
        var el = $('.member_flag');
        el.click(function(event) {
            if ($('.member_flag').width() < 100) {
                $('.member_flag').css('width', '316px');
                //hide videos, if any
                if ($('video').length > 0) {
                    $('video').hide();
                }
            }
        });
        el.blur(function() {
            $('.member_flag').css('width', '47px');
            //show videos, if any
            if ($('video').length > 0) {
                $('video').show();
            }
        });
    }
});

/**
 * Opens the subnavigation if any
 */
function openSubnav(el) {
    //hide videos, if any
    if ($('video').length > 0) {
        $('video').hide();
    }
    //check and save any other active arrows
    $('.navblock_pfeil_alwaysOn').hide();
    var noContent = false;
    //deactivate the old menu item
    if (activeNavigationItem != null) {
        activeNavigationItem.find('ul').hide();
        activeNavigationItem.removeClass('sfhover');
        //remove arrow
        $('#pfeil_' + activeNavigationItem.attr('id').substr(8)).hide();
    }
    //activate the new menu item
    if (activeNavigationItem == null) activeNavigationItem = $('<div id="tmpItem">');
    if (activeNavigationItem.attr('id') != $(el).parent().parent().attr('id')) {
        activeNavigationItem = $(el).parent().parent();
        //check for the content
        if (activeNavigationItem.find('ul li .navbox .navbox-middle .col1').html() != "") {
            activeNavigationItem.find('ul').show();
            activeNavigationItem.addClass('sfhover');
        } else {            
            noContent = true;
        }
    } else {
        //add arrow
        $('#pfeil_' + activeNavigationItem.attr('id').substr(8)).show();
        activeNavigationItem = null;
        //show videos, if any
        if ($('video').length > 0) {
            $('video').show();
        }
    }
    //return true, if there is no navigation item
    return noContent;
}

/**
 * Closes the actual navigation
 */
function closeSubnav() {
    //show videos, if any
    if ($('video').length > 0) {
        $('video').show();
    }
    if (activeNavigationItem != null) {
        activeNavigationItem.removeClass('sfhover');
        activeNavigationItem.find('ul').hide();
        //remove arrow
        $('#pfeil_' + activeNavigationItem.attr('id').substr(8)).hide();
        activeNavigationItem = null;
    }
    $('.navblock_pfeil_alwaysOn').show();
}

/**
 * Displays an arrow
 */
function show_pfeil(num) { 
    document.getElementById("pfeil_"+num).style.display = "block"; 
}

/**
 * Hides the arrow, if not the active menu item
 */
function hide_pfeil(num) { 
    //hide the arrow only if not active
    if (activeNavigationItem != null) {
        if (activeNavigationItem.attr("id") != "mainLink" + num) {
            document.getElementById("pfeil_"+num).style.display = "none"; 
        }
    } else {
        document.getElementById("pfeil_"+num).style.display = "none";
    }
}

//-->
