﻿(function($) {
	$.ColumnEqualizer = {
		init: function(sel) {
			$(sel || "div.columnEqualizer").each(function() {
				var $this = $(this),
				obj = $.extend({
					selector: "div.box > div.c > div.i",
					backupSelector: "div.box"
				}, $this.ParseClass(true))
				eles = $this.find(obj.selector);
				if (!eles.length) {
					eles = $this.find(obj.backupSelector);
				}
				eles = eles.filter(function() {
					var _this = this,
					parents = $(this).parents().filter(function() {
						for (var i=0, ele; ele = eles[i]; i++) {
							if (this == ele) {
								return true;
							}
						}
						return false;
					});
					if (parents.length) {
						return false;
					}
					return true;
				});
				
				eles.css("height", "");

				var max;
				eles.each(function() {
					var height = $(this).height();

					if (!max || height > max) {
						max = height;
					}
				});

				max = ($.browser.msie) ? max + 8 : max;
				eles.css("height", max + "px");
			});
		}
	};
	$(function() {
		setTimeout(function() {
			$.ColumnEqualizer.init();
		}, 100);
	});
})(jQuery);
