
// Setting equal height of blocks
// by Sergei T.

(function($){
	$.fn.setEqualBlocksHeight = function(count){
		if (count == 'all' || count > this.length) count = this.length;
		count = parseInt(count);
		if (count > 1)
		{
			this.css({height:'auto', 'min-height':0});
			for (var i=1; i<=this.length; i+=count)
			{
				var sameH = 0;
				for (var j=0; j<=count-1; j++)
				{
					if (this.get(i+j-1))
					{
						var blockH = this.eq(i+j-1).height();
						sameH = ( blockH > sameH) ? (sameH = blockH) : sameH
					}
				}
				for (var j=0; j<=count-1; j++)
				{
					if (this.get(i+j-1))
					{
						this.eq(i+j-1).css({'min-height': sameH});
						if (jQuery.browser.msie && jQuery.browser.version == '6.0') this.eq(i+j-1).height(sameH)
					}
				}
				
			}
		};
		if (count == 1) this.css({height:'auto', 'min-height':0});
		return this
	};
})(jQuery);
