

function equalizeColumns() {
   
    removeEmptySpots();
    addBlankSpotToColumn();
    
	var colsToEqualize = new Array();
	
	var highestColNum = 0;
	
	var highestCol;
	
	$(".colEq").each(function() {
		var spots = $(this).find('.spotEq').not('.spotParent .spotEq');
		heightAllSib = findSumHeightAllSpot(spots);
		

		colsToEqualize.push(this);
		if(heightAllSib > highestColNum){	
			highestColNum = heightAllSib;
			highestCol = this;
		}
		
	 });
	
	colsToEqualize = jQuery.grep(colsToEqualize, function(value) {
	        return value != highestCol;
	});

	
	for ( i=0; i <= colsToEqualize.length-1; i++)
	{
		var equalizeNum = 0;
		var lastSpot;
		var spots ={};

		spots = $(colsToEqualize[i]).find('.spotEq').not('.spotParent .spotEq');
		lastSpot = $(spots).last();
		heightAllSib = findSumHeightAllSpot(spots);

		equalizeNum = highestColNum - heightAllSib;
		
		var inner = $(lastSpot).height();
		var outer = $(lastSpot).outerHeight(true);
		
		
		lastSpot.css('height', $(lastSpot).outerHeight(true)+equalizeNum-(outer-inner));

	}
	
}

function findSumHeightAllSpot(spots){	
	var heightAllSpots = 0;
	$(spots).each(function() {	
		heightAllSpots += $(this).outerHeight(true);		
	 });
	
	return heightAllSpots;
}

function removeEmptySpots(){
	$(".colEq").each(function() {
		var spots = $(this).find('.spotEq:empty');
		$(spots).css('border','1px solid red');
		
		$(spots).remove();
	 });
}

function addBlankSpotToColumn(){
    $(".colEq").each(function () {

        if ($(this).children().length == 0) {

            $(this).append('<div class="spotEq"></div>');
        };

    });
	

	
	
	
}


