// Spaltenhöhe automatisch anpassen

window.addEvent('load', function() 
{
	//	box per row ermitteln
	//	gesamtzahl der boxen ermitteln
	//	separate durchläufe = gesamtzahl / box per row
	
	//	pro durchlauf setze boxen der jeweiligen reihe auf gleiche höhe
	
	var boxes = $$('#main .box');
	
	if (boxes.length > 1) {
	
		var boxPerRow = 2;
		var rowIndex = 1;
		
		boxes.each(function(el, index) 
		{
		
			if ( index < rowIndex * boxPerRow) {
			
				el.addClass('row' + rowIndex);
	
			} else {
			
				rowIndex++;
				el.addClass('row' + rowIndex);
				
			}
	
		}
		);
		
		for (var i = 1; i <= rowIndex; i++)
		{
		
			var max_height = 0;
			var boxesInRow = $$('#main .row' + i);
			
			boxesInRow.each(function(el, index) {
			
				max_height = Math.max(max_height, el.getSize().y);
		
			});
	
			boxesInRow.each(function(el, index) {
			
				el.setStyle('height', max_height);
		
			});
			
		}
		
	}
	
});
