var items_centered_obj, items_centered_obj2;
var is_double = true;
var is_tripple = false;
function checkWidth() {
	if (!items_centered_obj) items_centered_obj = $('#items-centered');
	if (!items_centered_obj2) items_centered_obj2 = $('#items-centered2');

	if (550 < items_centered_obj.width() && !is_tripple) {
		is_tripple = true;
		is_double = false;
		items_centered_obj.find('div.item2').each(function() {
			this.style.width = '33.2%';
		});
		items_centered_obj2.find('div.item2').each(function() {
			this.style.width = '33.2%';
		});
	} else if (550 > items_centered_obj.width() && !is_double) {
		is_double = true;
		is_tripple = false;
		items_centered_obj.find('div.item2').each(function() {
			this.style.width = '49.9%';
		});
		items_centered_obj2.find('div.item2').each(function() {
			this.style.width = '49.9%';
		});
	}
}
function checkHeight(obj) {
	var th = 0;
	//Находим максимальную высоту блока
	obj.find('div.item2').each(function() {
		th = Math.max(th, $(this).height());
//		alert(th);
	});

	if (215 < th) th += 10; //если высота блока больше чем при верстке, добавляем 10 пкс для отступа

	//устанавливаем все блоки в одинаковую высоту
	obj.find('div.item2').each(function() {
		$(this).css('height', th + 'px');
	});
}
$(document).ready(function() {
	checkWidth();
	checkHeight(items_centered_obj);
	checkHeight(items_centered_obj2);
});
$(window).resize(checkWidth);

