/* equalColumnHeights equals the height of divs inside the given element
 * can equal also columns starting at misc positions
 *
 * @author  Gregor Nathanael Meyer http://der-meyer.de
 * @license cc-by-sa http://creativecommons.org/licenses/by-sa/3.0/de/
 *
 * @return  jQuery
 * @param   string   filter    a css string to equal only a matched subset of elements
 */
$.fn.equalColumnHeights = function(filter) {
  var highestColumnBottomY = 0;
  var columns = $(this).children(filter);
  
  // find the highest bottom-offset of all columns
  columns.each(function(){
    if( highestColumnBottomY < $(this).offset().top + $(this).outerHeight() ) {
      highestColumnBottomY = $(this).offset().top + $(this).outerHeight();
    }
  });
  // set all column's min-height properties to reach the bottom-offset of the highest one, considering the top-position
  columns.each(function(){
    var newHeight = highestColumnBottomY
      - $(this).offset().top
      - parseInt($(this).css('paddingTop'))
      - parseInt($(this).css('paddingBottom'))
      - parseInt($(this).css('borderTopWidth'))
      - parseInt($(this).css('borderBottomWidth'));
    $(this).css('height', newHeight );
  });
  return this;
}