Array.prototype.clean = function(deleteValue) {
  for (var i = 0; i < this.length; i++) {
    if (this[i] == deleteValue) {         
      this.splice(i, 1);
      i--;
    }
  }
  return this;
};

$(function(){
	fixCollectionHeight($('.csc-header, .news-latest-title, .news-single-title, .region-search-results-item-name'));
});

function fixCollectionHeight(collection) {	
	var max_height = 0;
	var collection_by_offset_top = [];
	for(var i = 0; i < collection.length; i ++) {
		var offset = collection.eq(i).offset();
		if(!collection_by_offset_top[offset.top]){
			collection_by_offset_top[offset.top] = [];
		}
		collection_by_offset_top[offset.top][i] = collection.eq(i);
	}
	collection_by_offset_top.clean(undefined);
	$.each(collection_by_offset_top, function(n, val){
		if(typeof(val) == 'object') {
			val.clean(undefined);
			max_height = 0;
			$.each(val,function(num,value) {
				if(typeof(value) == 'object'){
					if( value.height() > max_height) max_height = value.height();	
				}		
			});
			$.each(val,function(num,value) {
				if(typeof(value) == 'object'){
					value.height(max_height);	
				}		
			});
	}});
}