var bio_show; // = 1;

$(function() {
    bio_show = 1;
    if(document.location.href.match('#.+')) {
        var div_id = document.location.href.match('#.*').toString().replace('#bio', '');
        if($('div#bio' + div_id).length > 0) {
            bio_show = parseInt(div_id);
        } else {
            document.location.href = document.location.href.split('#')[0] + '#bio1';
        }
    }
    $('div#inner_bios div#mid_contents').html($('div#bio' + bio_show.toString()).html() + '<div class="clear"></div>');
    $('a#bio_left').click(function() { shift_left(); return false; });
    $('a#bio_right').click(function() { shift_right(); return false; });
})

var animate_and_shift = function(bio_show) {
    var new_bio = 'div#bio' + bio_show;
    $('div#inner_bios div#right_contents').html($(new_bio).html() + '<div class="clear"></div>');
    $('div#inner_bios div#left_contents').animate({
        width: '0px'
    }, 250, 'swing', function() {
        $('div#inner_bios').html('<div id="left_contents" class="shifter"></div>' + 
            '<div id="mid_contents" class="shifter">' + $('div#right_contents').html() + '</div>' +
            '<div id="right_contents" class="shifter"></div>');
        document.location.href = document.location.href.split('#')[0] + '#' + $(new_bio).attr('id');
    });
}

var shift_right = function() {
    bio_show++;
    if($('div#bio' + bio_show).length < 1) { bio_show = 1; }
    animate_and_shift(bio_show);
    if($('input#in_production').length > 0) {
        pageTracker._trackEvent('Home Page Bios', 'Home Right Shift', 'Block: ' + bio_show);
    }
};
var shift_left = function() {
    bio_show--;
    if(bio_show < 1) { bio_show = $('div.bio_block').length; }
    $('div#left_contents, div#right_contents, div#mid_contents').css('float', 'right');
    animate_and_shift(bio_show);
    if($('input#in_production').length > 0) {
        pageTracker._trackEvent('Home Page Bios', 'Home Left Shift', 'Block: ' + bio_show);
    }
};

