﻿$(document).ready(function() {
    // activate the first thumb on load
    var li = $("#bioThumbs li:first");
    activateThumb(li);

    // show names on hover

    // activate thumbs on click
    $("#bioThumbs li a").click(function() {
        // hide old bio
        deactivateThumb($('.active-thumb'));

        // activate new bio
        activateThumb($(this).parent());
        return false;
    });
});

function activateThumb($li) {
    // set variables
    $img = $li.find("img");
    $href = $li.find("a").attr("href");
    $src = "/images/headshots/thumbs/" + $href.substring(1) + "-on.jpg";
    
    // switch out the thumbnail
    $img.attr({ src: $src });

    // show the bio
    $($href).fadeIn('fast');

    // add the active class
    $li.addClass('active-thumb');
}

function deactivateThumb($li) {
    // set variables
    $img = $li.find("img");
    $href = $li.find("a").attr("href");
    $src = "/images/headshots/thumbs/" + $href.substring(1) + "-off.jpg";

    // switch out the thumbnail
    $img.attr({ src: $src });

    // hide the bio
    $($href).hide();

    // remove the active class
    $li.removeClass('active-thumb');
}