/*!
 * Equal Heights Plugin
 * Version 1.0.0
 *
 * Copyright © 2009,2010 David Young & Cape Fear Webmasters, Inc.
 * http://www.cfwebmasters.com/
 * http://dcyoung.com/
 * Released under the GNU GPL Version 2 license.
 * 
 *
 * Usage:
 * 
 *	jQuery('.columnclass').cfwiEqualize({
 *		set:'width',
 *		margins:false
 *	});
 *
 *	@param set: (string) 'width|height' - which axis is being set. Default is 'height'
 *	@param margins: (boolean) true|false - whether to include margins in the calculations. Default is false
 *
 */
if(typeof(jQuery)!=='undefined'&&window.jQuery){
	(function($){
		jQuery.fn.cfwiEqualize=function(args){
			var m_params={'set':'height','margins':false},m_max={'width':0,'height':0};
			if(typeof(args)==='object'&&args!==null){$.extend(m_params,args);}
			if(typeof(m_params.margins)!=='boolean'){m_params.margins=false;}
			this.each(function(){
				var $this = jQuery(this);
				m_max.width = Math.max($this.outerWidth(m_params.margins),m_max.width);
				m_max.height = Math.max($this.outerHeight(m_params.margins),m_max.height);
			});
			return this.each(function(){
				var $a=jQuery(this);
				if(typeof(m_params.set)==='string'&&typeof(m_params.set)!=='undefined'){
					switch(m_params.set.toLowerCase()){
						case 'width':
							$a.css({'min-width':(m_max.width+'px')});
							break;
						case 'height':
							$a.css({'min-height':(m_max.height+'px')});
							break;
						default:
							$a.css({'min-height':(m_max.height+'px')});
							break;
					}
				}else{
					throw("String values of 'width' or 'height' are the only valid options for parameter: 'set'");
				}
			});
		}
	})(jQuery);	
}
