jQuery(document).ready(function(){

    // ====================================
    // = Content showing for main buttons =
    // ====================================
    
    function hideContent(){
        jQuery("#software_content").hide();
        jQuery("#consulting_content").hide();
        jQuery("#company_content").hide();
        jQuery("#blog_content").hide();
    }
    
    // The function to show the main content by layer
    function showContent(layer, animate){
    
        hideContent();
        
        jQuery("#" + layer + "_content").show();
        
        if (animate === true) 
        {
            jQuery('html,body').animate({
                scrollTop: jQuery("#nav").offset().top - 16
            }, 1000, "swing");
        }
        
        window.location.hash = layer;
    }
    
    // Set up the on click functions for the different menus
    jQuery("#nav").children().click(function(){
        showContent(jQuery(this).attr("id").split("_")[1], true);
    });
    
    
    hideContent();
    
    // If there is a location has we open the layer with the content and scroll to it,
    // but only if we're not coming from the same url, because then we'd like to end up
    // at the scroll position we were.
    if (window.location.hash && document.referrer != window.location) {
        showContent(window.location.hash.replace("#", ""), false);
    }

});

