  //edited by RQ 7/16/10
  //changed column id string to "box"
  
(function($) {

	function getMaxOfArray(numArray) {
		return Math.max.apply(null, numArray);
	}

	$.fn.equalHeight = function(params) {
	
		var options = {
			returnHeight: false
		}
	
		var heights = []
		  , maxHeight;
		
		$.extend(options, params);
		
		this.each(function() {
			heights.push($(this).boxHeight());
		});
		
		maxHeight = getMaxOfArray(heights);	
		this.setBoxHeight(maxHeight);
				
		return options.returnHeight ? maxHeight : this;
	}

})(jQuery);

(function($) {

	$.fn.boxHeight = function(params) {
		var options = {
			includeMargin: false
		}
		$.extend(options, params);
		
		var topBorder 	 = parseInt(this.css('border-top-width'))    || 0
		  , bottomBorder = parseInt(this.css('border-bottom-width')) || 0
		  , topMargin 	 = options.includeMargin ? (parseInt(this.css('margin-top')) || 0) : 0
		  , bottomMargin = options.includeMargin ? (parseInt(this.css('margin-bottom')) || 0) : 0;
		
		return this.innerHeight() + topBorder + bottomBorder + topMargin + bottomMargin;
	}
	
	$.fn.setBoxHeight = function(height, params) {
		var options = {
			includeMargin: false
		}
		$.extend(options, params);
		
		this.each(function() {
		
			var $this = $(this);
			
			var topBorder = parseInt($this.css('border-top-width')) || 0
			  , bottomBorder = parseInt($this.css('border-bottom-width')) || 0
			  , topPadding = parseInt($this.css('padding-top')) || 0
			  , bottomPadding = parseInt($this.css('padding-bottom')) || 0
			  , topMargin 	 = options.includeMargin ? (parseInt($this.css('margin-top')) || 0) : 0
			  , bottomMargin = options.includeMargin ? (parseInt($this.css('margin-bottom')) || 0) : 0
			  , newHeight = height - topBorder - bottomBorder - topPadding - bottomPadding - topMargin - bottomMargin;
			
			$this.css('height', newHeight + 'px');
			
		});
		return this;
	}

})(jQuery);
