/* main.js
 * JS functions for sfuco-site
 * Reinier E.
 * revangel@sfu.ca
 * 2016
 */

jQuery(document).ready(function()
{

    var verticalNav = jQuery('#vertical-nav');

    // Initialize the vertical nav section as hidden
    // since the top of the page will have the
    // horizontal nav visible
    verticalNav.hide();

    jQuery(window).on("scroll", function()
    {
        updateVerticalNav();
    });

    function updateVerticalNav ()
    {
        var windowPosition = jQuery(window).scrollTop();
        var topOfPage = jQuery("section:first").offset().top;

        if(windowPosition >= topOfPage)
        {
            verticalNav.fadeIn();
            updateNavColors();
        }
        else
        {
            verticalNav.fadeOut();
        }
    }

    function updateNavColors ()
    {
        var windowPosition = jQuery(document).scrollTop();

        jQuery("section").each(function(index)
        {
            if(index < jQuery("section").size()-1)
            {
                var currentSectionTop = jQuery(this).offset().top;
                var currentSectionBottom = currentSectionTop + jQuery(this).outerHeight(true);

                var currentSection = jQuery("#vertical-nav a:eq(" + index + ")");
                var currentSectionID = jQuery("#vertical-nav a:eq(" + index + ")").attr("id");
                
                if(windowPosition >= currentSectionTop && windowPosition < currentSectionBottom)
                {

                    currentSection.addClass("active-nav");
                    jQuery("#vertical-nav a").not("#" + currentSectionID).each(function()
                    {
                        jQuery(this).removeClass("active-nav");
                    });
                }

            }

        });

    }

});

@@ -81,16 +81,17 @@
 16%0A */%0A%0A
+%0A
 jQuery(d
@@ -122,299 +122,8 @@
 )%0A%7B%0A
-%0A    var verticalNav = jQuery('#vertical-nav');%0A%0A    // Initialize the vertical nav section as hidden%0A    // since the top of the page will have the%0A    // horizontal nav visible%0A    verticalNav.hide();%0A%0A    jQuery(window).on(%22scroll%22, function()%0A    %7B%0A        updateVerticalNav();%0A    %7D);%0A%0A
     
@@ -1038,32 +1038,16 @@
 (%22id%22);%0A
-                
 %0A       
@@ -1460,20 +1460,984 @@
     %7D);%0A
-%0A
     %7D%0A%0A
+    function closeModalBox()%0A    %7B%0A        // Since the exec section's modal boxes each have%0A        // unique hashes, it's easier to check for whether%0A        // the modal box is from one of the other sections%0A        // with hashes that we already know beforehand%0A        if(window.location.hash == %22#contact-form%22)%0A        %7B%0A            window.location.hash = %22#contact%22;%0A        %7D%0A        else%0A        %7B%0A            window.location.hash = '#execs';%0A        %7D%0A    %7D;%0A%0A%0A    var verticalNav = jQuery('#vertical-nav');%0A%0A    // Initialize the vertical nav section as hidden%0A    // since the top of the page will have the%0A    // horizontal nav visible%0A    verticalNav.hide();%0A%0A    jQuery(window).on(%22scroll%22, function()%0A    %7B%0A        updateVerticalNav();%0A    %7D);%0A%0A%0A    jQuery(%22.modal-overlay%22).on(%22click%22, function(e)%0A    %7B%0A        if(e.target != this)%0A        %7B%0A            return; // Only close if click is outside window%0A        %7D%0A        closeModalBox();%0A    %7D);%0A
 %7D);%0A

Add modal window close on click