function centerImages() {
	$('.photo').each(function(){
		w = $(this).find('IMG').width();
		h = $(this).find('IMG').height();
		f = $(this).find('.frame').width();
		
		if (h > w) { 
			// foto verticale
			$(this).find('IMG').width(f); 
		}
		else { 
			// foto orizzontale
			$(this).find('IMG').height(f); 
			
			w = $(this).find('IMG').width();
			
			offset = (w - f) / 2;
			offset = '-'+ offset +'px';
			
			$(this).find('IMG').css('left',offset);
		}
	});
}

$(function() { centerImages(); });