postHeight = new Array();

// on DOM
$(function(){setColumns();});

// on load
$(window).load(function(){setColumns();});

// on resize
$(window).resize(function(){setColumns();});

function setColumns()
{
    var columns = Math.max(3, parseInt($('body').innerWidth() / 230));
    
    $('#rap').height(50)
    
    $('#content').css('position', 'relative');
    
    $('.liquidGrid').css({
        'position': 'absolute',
        'float': 'none',
        'width': '220px'});
    
    for (x = 0; x < columns; x++) postHeight[x] = 0;
    
    x = 0;
    
    // for each post arrange
    $('.liquidGrid').each(function()
    {
        $(this).css({
            'left': x * 230,
            'top': postHeight[x]});
        
        lastHeight = $(this).offset().top + $(this).height();
        
        postHeight[x] += parseInt($(this).outerHeight()) + 10;
        
        if(x <= (columns - 2)) x++; else x = 0;
		
		if($(this).attr('id') == 'navigation') x--;
        
        if($.browser.version < 7 && $.browser.msie)    $('#footer').css({
            'position': 'absolute',
            'left': 0,
            'top': lastHeight + 50});
        else
            if(lastHeight > $('#rap').height()) $('#rap').height(lastHeight + 50);
    });
}
