// main content and sidebar must match height
$(window).load(function () {
    var content_height = $('#content').height();
    var sidebar_height = $('#sidebar').height();

    var max_height = Math.max(content_height, sidebar_height);

    $('#content, #sidebar').height(max_height);
});

// get teh twitter feed
$(window).load(function () {
    var oneMonthAgo = new Date();
    oneMonthAgo.setMonth(oneMonthAgo.getMonth()-1);

    $("#twitter").tweet({
        username: "thebrainbuzz",
        count: 6,
        //since: oneMonthAgo,
        loading_text: 'Loading Twitter feed...'
    });
});

// center nav
$(window).load(function () {
    var buttons_width = 0;

    $("#navigation > .nav_item").each(function () {
        buttons_width += $(this).outerWidth(true);
    });

    var nav_width = $("#navigation").width();

    $("#navigation").css('margin-left', (nav_width - buttons_width) / 2);
});

// nav submenus
$(window).load(function () {
    $('#navigation div.nav_item').each(function () {
        $(this).hover(
            function () {
                $(this).addClass('hover');
                $(this).children('.nav_sub').show();
            },
            function () {
                $(this).removeClass('hover');
                $(this).children('.nav_sub').hide();
            }
        );
    });
});

// shadows
$(window).load(function () {
    $('.has_shadow').each(function () {
        var w = $(this).outerWidth();
        var h = $(this).outerHeight();

        for (var i = 1; i < 4; i++)
        {
            var $shadow_box_e  = $('<div class="shadow"></div>').css({ width: i+'px',      height: (h-i)+'px',  top:    i+'px',     right: '-'+i+'px', opacity: '0.1' });
            var $shadow_box_s  = $('<div class="shadow"></div>').css({ width: (w-i)+'px',  height: i+'px',      bottom: '-'+i+'px', left:  i+'px',     opacity: '0.1' });
            var $shadow_box_se = $('<div class="shadow"></div>').css({ width: i+'px',      height: i+'px',      bottom: '-'+i+'px', right: '-'+i+'px', opacity: '0.1' });

            $(this).append($shadow_box_e);
            $(this).append($shadow_box_s);
            $(this).append($shadow_box_se);
        }
    });
});

// rounded corners
//$(window).load(function () {
//    $('.entry blockquote').each(function () {
//        var $this = $(this);
//
//        $this.addClass('has_rounded_corners')
//
//        $('<div class="rounded_corner tl"></div>').prependTo($this);
//        $('<div class="rounded_corner tr"></div>').prependTo($this);
//        $('<div class="rounded_corner bl"></div>').prependTo($this);
//        $('<div class="rounded_corner br"></div>').prependTo($this);
//    });
//});

// sans bottom border
$(window).load(function () {
    // last widget (on sidebar) has no bottom border
    $('#sidebar .widget:last').css('border-bottom', 'none');

    // last submenu item (in nav) has no bottom border
    $('#navigation .nav_sub').each(function () {
        $(this).find('.nav_item:last').css('border-bottom', 'none');
    });
});

