(function($) {
	$.fn.match_heights = function() {
		this.height(this.max_height());
		
		return this;
	}
	
	$.fn.max_height = function() {
		var max_height = 0;
		this.each(function() {
			if($(this).height() > max_height)
				max_height = $(this).height();
		});
		
		return max_height;
	}
	
	$.fn.match_heights_for_sub_group = function(length_of_sub_group) {
		var total_length = this.length;
		
		for(var i = 0, sub_group; i < total_length / length_of_sub_group; i++) {
			sub_group = [];
			
			for(var j = 0, index; j < length_of_sub_group; j++) {
				index = (i * length_of_sub_group) + j;
				if(this[index])
					sub_group.push(this[index]);
			}
			
			$(sub_group).match_heights();
		}
	}
})(jQuery);

function match_heights_loop(not_set, set) {
	var max_height = 0, last_max_height = 1;
	
	while(max_height != last_max_height) {
		last_max_height = max_height;
		max_height = $([set,not_set]).max_height();
		$(set).height(max_height);
	}
	
}
