function showSubsites() {
    document.getElementById('subsite').style.display="block";
}

function hideSubsites() {
    if (!event.fromElement.contains(event.toElement) &&!document.getElementById('subsite').contains(event.toElement))
        document.getElementById('subsite').style.display="none";
}

function toggleSubsites(){
    $('#subsite').toggle();
    return false;
}

function findHeight(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curtop += obj.offsetTop
        }
    }
    return curtop;
}

$.fn.equalHeights = function(px) {
    $(this).each(function(){
        var currentTallest = 0;
        $(this).children().each(function(i){
            if ($(this).height() > currentTallest) {
                currentTallest = $(this).height();
            }
        });
        if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
        // for ie6, set height since min-height isn't supported
        if ($.browser.msie && $.browser.version == 6.0) {
            $(this).children().css({
                'height': currentTallest
            });
        }
        $(this).children().css({
            'min-height': currentTallest
        });
    });
    return this;
};

function setFooter(content){
    heightMiddle = findHeight(document.getElementById('heightcheck'));
    heightLeftMenu = findHeight(document.getElementById('heightcheck2'));
    if (heightLeftMenu > heightMiddle) {
        $('#heightcheck2').after('<div id="footer">'+ content +'</div>');
    } else {
        $('#heightcheck').after('<div id="footer" class="footerleft">'+ content +'</div>');
    }

}

function setFpFooter(content){
    var leftHeight = $('#leftSide').height();
    if(leftHeight < 700){
        var newheight = (700-leftHeight);
        $('#heightcheck2').height(newheight);
    }
    $('#heightcheck2').after('<div id="footer">'+ content +'</div>');
}

function setCurrentTab(){
    // Get the URL from the crumble path
    crumbleUrl = $('#snelNav a:last').attr('href').split('/');
    currentUrl = crumbleUrl[1];
    currentPath = window.location.pathname;

    // Walk through each menu item, and check if we match the first
    // part of the crumble url. the exception is for the contact page
    $('#navTabs ul').children().each(function(){
        var thisLi = $(this);
        if (thisLi.is("li")) {
            thisA = thisLi.find('a');
            thisHref = thisA.attr('href');

            var hrefParts = thisHref.split('/');
            first = hrefParts[1];

            if(first == currentUrl){
                if(currentPath == '/over_saxion/contact/adres/' ){
                    $('.navTabCurrent').removeClass('navTabCurrent');
                    thisA.addClass('navTabCurrent');
                } else {
                    thisA.addClass('navTabCurrent');
                    return false;
                }
            }
        }
    });
}