/**
 * MaxiScale management team JS.
 * 
 * 
 */

/**
 * Runs on document load.
 * 
 * 
 */
$(document).ready(function() {
    assignTeamPhotoHandlers();
});


/**
 * Assign event handlers to team photo links.
 * 
 * 
 */
function assignTeamPhotoHandlers() {
    $('#team_photos a').each(function(i) {
        $(this).bind('mouseover', teamPhotoOver); 
        $(this).bind('mouseout', teamPhotoOut); 
    });
}


/**
 * Team photo mouseover handler.
 * 
 * 
 */
function teamPhotoOver() {
    //$('#team_photos a').removeClass('inactive');
    // "this" inside each() loop points to current iteration. Save current.
    var current = this;
    // Add a class of inactive to every team photo link, except current.
    $('#team_photos a').each(function(i) {
        if (current != this && !$(this).hasClass('inactive')) {
            $(this).addClass('inactive');
        }
    });
    // Determine numeric portion of id, so we can match it to team photo text.
    var id = (/^team_photo_(\d)$/).exec($(this).parent().attr('id'))[1];
    // Hide all team text bloks.
    $('.team_text').hide();
    // Show current team text block.
    $('#team_text_' + id).show();
}


/**
 * Team photo mouseout handler.
 * 
 * 
 */
function teamPhotoOut() {
    // Remove inactive class from all team photos.
    $('#team_photos a').removeClass('inactive');
    // Hide all team text blocks.
    $('.team_text').hide();
    // Show default team text.
    $('#team_text_default').show();
}

