/**
 * Equal_Height.js  カラムの高さを合わせるプラグイン
 *
 * Copyright (C) unvent
 * Dual licensed under the MIT <http://www.opensource.org/licenses/mit-license.php>
 * and GPL <http://www.opensource.org/licenses/gpl-license.php> licenses.
 * Date: 2009-06-05
 * @author I <http://unvent.jp/>
 * @version 1.0
 *
 **/
function ehfunc(a,b){
 return (a-b);
}

(function ($) 
{
	$.fn.equal_height=function(obj)
	{
		if(obj != null || obj != undefined)
		{
			var max_height = ((!isNaN(obj.max) || isFinite(obj.max)) && obj.max > 0) ? obj.max : 0;
			var min_height = ((!isNaN(obj.min) || isFinite(obj.min)) && obj.min > 0) ? obj.min : 0;
			var just_height = ((!isNaN(obj.just) || isFinite(obj.just)) && obj.just > 0) ? obj.just : 0;
		}
		
		var arrHeight = new Array();
		
		$(this).each(function () {
			
			arrHeight.push($("#" + this.id).height());
			
			
		});
		
		arrHeight.sort(ehfunc);
		var val = arrHeight[arrHeight.length - 1];


		if(max_height > 0)
		{
			val = (val >= max_height) ? max_height : val;
		}
		
		if(min_height > 0)
		{
			val = (val >= min_height) ? min_height : val;
		}
		
		if(just_height > 0)
		{
			val = (val >= just_height) ? just_height : val;
		}
				
		
		$(this).each(function () {
		    $("#" + this.id).height(val);	   
		});
		
	}
})(jQuery);

