
$('.section').hide();
$('#about').show();
$('#b_about').addClass('selected');
setupButtons();

function setupButtons() {
    $('.button').attr('href', '#');
    $('.button').click(function() {
        showSection(this);
    });
}

function showSection(button) {
    sec = button.id.substring(2);
    if($('#b_' + sec).hasClass('selected')) {
        return;
    }
    //$('.section').filter(':visible').slideUp('fast');
    $('.section').filter(':visible').slideUp('fast');
    $('.button').removeClass('selected');
    $('#' + sec).filter(':hidden').slideDown('fast');
    $('#b_'  +sec).addClass('selected');

    if(sec == 'about') {
        //$('#grid').width(440, 'slow');
        $('#grid').animate({
            width: 440,
            height: 440
        }, 200);
        $('#container').animate({
            width: 870
        }, 200);
    } else {
        $('#grid').animate({
            width: 220,
            height: 880
        }, 200);
        $('#container').animate({
            width: 650
        }, 200);
    }
}

function twitterCallback(tweets) {
    var tweet = tweets[0].text;
    var re = /(http:\/\/\S+)/;
    tweet = tweet.replace(re, "<a href='$1'>$1</a>");

    $('#tweetbox #tweet').html(tweet);
}

function flickrCallback(photos) {
    if(photos.items.length < 1) {
        return;
    }

    var rand = Math.floor(Math.random() * photos.items.length);
    var photo = photos.items[rand].media.m;

    $('#pictureframe img').attr('src', photo);
}

