/* ***********************************************************
 * jQuery Plugin jquery.adjust-height.js
 * Version: 1.0
 * Author: Kazuyoshi Uechi
 * -----------------------------------------------------------
 * History:
 ********************************************************** */
 
(function($){
	
	$.fn.adjustHeight = function(){
		
		$(this).each(function(){
			apply(this);
		});
		
		return this;
	}
	
	function apply(selector){
		$(selector).each(function(){
			var max    = 0;
			var offset = null;
			var elems  = [];
			$('>*', this).each(function(){
				if( offset != $(this).offset().top ){
					$(elems).height(max);
					max = 0;
					offset = $(this).offset().top;
					elems = [];
				}
				max = Math.max( $(this).height(), max||0 );
				elems.push(this);
			});
			$(elems).height(max);
		});
	}
	
})(jQuery);
