﻿function setColumns(container, leftCol, rightCol)
{
	var columns = $(container).childElements();
	var maxHeight = (columns[0].getHeight() + columns[1].getHeight() - 10) * 0.45;
	var currentHeight = 0;
	
	var txtElements = $(leftCol).childElements();
	txtElements.each(function(el){ 
		el = el.remove();	
		if(currentHeight <= maxHeight)
		{ 
			$(leftCol).insert(el);
			currentHeight += el.getHeight();
		}
		else
		{ $(rightCol).insert(el); }
	});
}

function setColumnsWithImage(pos, container, leftCol, rightCol)
{
	var columns = $(container).childElements();
	var maxHeight = (columns[0].getHeight() + columns[1].getHeight() - 10) * 0.45;
	var currentHeight = 0;
	var imgHeight = 0;
	
	txtElements = $(leftCol).getElementsBySelector('p');
	txtElements.each(function(el){ el = el.remove(); });
	switch(pos)
	{
		case 'NW':
		case 'SW':
			imgHeight = columns[0].getHeight();
			break;
		case 'NE':
		case 'SE':
			imgHeight = columns[1].getHeight();
			break;
	}
	txtElements.each(function(el) {
		if(currentHeight <= maxHeight)
		{ 
			$(leftCol).insert(el);
			currentHeight += el.getHeight();
		}
		else
		{ $(rightCol).insert(el); }
	});
}