function columnsHeight() {
	// Make sure the columns have equal heights (for column background colors)
    jQuery('#main-content > .inner').css('min-height',jQuery('#sidebar > .inner').height()-jQuery('#main-widgets-container').height()-42);
    jQuery('#sidebar > .inner').css('min-height',jQuery('#main-content > .inner').height()+jQuery('#main-widgets-container').height()+42);
}

jQuery(document).ready(function() {
    columnsHeight();
});

jQuery(window).load(function() {
    columnsHeight();
});



/**
 * Meerstad specific (helper) functions.
 */
var meerstad = {};

meerstad.addMoreLink = function (content) {
    var first = content.children().first(),
        rest = first.siblings(),
        button = jQuery('<a href="#" class="more">lees meer</a>'),
        button2 = jQuery('<a href="#" class="more">lees minder</a>');

    if (rest.length) {
        first.append(button);
        rest.hide();
        rest.last().append(button2);
    }

    button.click(function (e) {
        rest.show();
        columnsHeight();
        button.hide();
        columnsHeight();
        e.preventDefault();
        return false;
    });

    button2.click(function (e) {
        rest.hide();
        jQuery('#sidebar > .inner').css('min-height', '0');
        columnsHeight();
        button.show();
        e.preventDefault();
        return false;
    });
};

meerstad.moveSpecTable = function (content, target) {
    var table;

    if (!target.length) {
        return;
    }

    target.hide();

    table = content.find('table').filter(':last');
    if (table.length) {
        table
            .detach()
            .addClass('spec-table')
            .appendTo(target);

        target.show();
    }
};
