function arm_focus_on_form_errors() {
    $(".form-errors a").click(function(e) {
        $(e.target.getAttribute('href')).focus()
    });
}

function highlight_current_section() {
    var section = window.location.pathname.split("/")[1];
    if(section) {
        $("dd a[href='/" + section + "']").parent().addClass("active");
    }
}

function highlight_current_craftsman() {
    var section = window.location.pathname;
    if(section) {
        $("aside#our-team ul li a[href='" + section + "']").parent().addClass("active");
    }
}

function smooth_scroll()
{
    $("a").bind('click', function(event) {
        var $anchor = $(this);

        $('html, body').stop().animate({
            scrollTop: $($anchor.attr('href')).offset().top
        }, 1000);

        event.preventDefault();
    });
}

$(document).ready(function () {
    arm_focus_on_form_errors();
    highlight_current_section();
    smooth_scroll();
    highlight_current_craftsman();
});
