function resizeImg() {
    ww = $(window).width();
    wh = $(window).height();

    areaw = ww-40;
    areah = wh-67;

    $('#imagearea').width(areaw);
    $('#imagearea').height(areah);

	if($('#metacaption').size()>0) {
    	areah = wh-167;
	}
    images = $('#imagearea').find('img');
    
    totw = 0;
    toth = 0;
    images.each(function(){
        totw += parseInt($(this).attr('w'));
        h = parseInt($(this).attr('h'));
        if(h > toth) {
            toth = h;
        }
    });

    if(areaw/areah > totw/toth) {
        //h
        factor = areah / toth;
    } else {
        //w
        factor = areaw / totw;
}
    if(factor > 1) factor = 1;

    images.each(function(){
        ow = $(this).attr('w');
        oh = $(this).attr('h');
        neww = Math.round(ow*factor);
        $(this).width(neww)
        $(this).attr('neww', neww);
        
        newh = Math.round(oh*factor);
        $(this).height(newh)
        $(this).attr('newh', newh);

        tm = Math.round((areah - newh)/2.2)
        $(this).css('top', tm+'px');
    });
}
