function get_common_class(a, b) {
    var common = null;

    a = a.split(' ');
    b = b.split(' ');

    for(i = 0; i < a.length; i ++) {
        for(j = 0; j < b.length; j ++) {
            console.log('checking ' + a[i] + ', ' + b[j]);
            if(a[i] == b[j]) {
                common = a[i];
                break;
            }
        }

        if(common != null) {
            break;
        }
    }

    return common;
}

function show_bio(event) {
    event.stopImmediatePropagation();

    var link = $(this);
    var bio_class = link.parent()[0].className.split(' ')[0];
    var title = this.innerHTML;

    var bio_display = $('#bio-display');

    bio_display.fadeTo(500, 0.01, function() {
        bio_display[0].innerHTML = '';

        $('div.' + bio_class).each(function() {
            bio_display.append(this.innerHTML);
        });

        bio_display.fadeTo(500, 0.95);
    });

    return false;
}

$(function() {
    $('#bio-display').hide();

    $('.bio').each(function() {
        $(this).hide();
    });

    $('.team-member').each(function() {
        var heading = $(this);
        var e = $(document.createElement('a'))
        e[0].setAttribute('href', '#');
        e.click(show_bio);
        e.html(heading.html());

        heading.html(e);
    });
});
