$(function(){
    $('.links a').each(function(){
        var text = $(this).text();
        var pattern = /\((.*?)\)/;
        var matches = text.match(pattern);
        if(matches){
			text = text.replace(matches[0], '');
            $(this).html(text+'<span>'+ matches[1] +'</span>');
        }
    });
    
    $('.post.free').autoHeight();
});

jQuery.fn.autoHeight = function(options) 
{
    var settings = {
        minHeight   : false,
        limitHeight  : false,
        ignore  : '',
        padding : 10
    }

    if(options) {
        jQuery.extend(settings, options);
    };

    var maxHeight = 0;

    this.not(settings.ignore).each(function(){
        if ($(this).height() > maxHeight){
            if(settings.limitHeight && maxHeight >= settings.limitHeight) {
                maxHeight = settings.limitWidth;
            } 
            else if(settings.minHeight && maxHeight <= settings.limitHeight)
            {
                maxHeight = settings.minHeight;
            } 
            else 
            {
                maxHeight = $(this).height();
            }
        }
    });  

    this.not(settings.ignore).height(maxHeight + settings.padding);

}
