var container_id = '.begun-resize-container';
var image_id = '.begun-resize-image';
var sizes = [];

$(window).load(image_resize_init);
$(window).resize(image_resize);

function image_resize_init(){
    sizes = $(container_id+' img'+image_id).size();    
}

function image_resize(){
    var c_width = $(container_id).width();
    $.each($(container_id+' img'+image_id), function(key, val) {
        if ($(this).width() > c_width || $(this).attr('resize') == 1) {
            var k = $(this).width() / c_width;
            $(this).height(Math.round($(this).height() / k));
            $(this).width(c_width);
            $(this).attr('resize', 1);
        }
    });
}
