$(function() {
    
    // Instead of Target = _blank use (rel=external)
    $('a[rel=external]').attr('target','_blank');
    
    // set active class in main nav on click
    $('#nav a').click(function() {
        $('#nav a').removeClass('active');
        $(this).addClass('active');
    });
    
    // set active class in main nav on load
    var hash = location.hash;
    if (hash){
        $('#nav a[href='+hash+']').addClass('active');
    }
    
    // Scroll to Sections
    $('a[href*=#]').click(function(){
        var scrollToHash = $(this).attr('href');
        var offsetY = $(scrollToHash).offset();
        $('html,body').animate({scrollTop: offsetY.top - 0}, 600, 'swing');
        return false;
    });
    
    
});
