jQuery.fn.fitcol = function (o) {
    o = $.extend({
        format: true
    }, o || {});

    return this.each(function () {
        var width = $(this).width();
        $('img', $(this)).each(function () {
            if (o.format) {
                $(this).removeClass().after('<div></div>');
            }
            if ($(this).width() > width) {
                var height = Math.round($(this).height() * width / $(this).width());
                $(this).attr({
                    width: width,
                    height: height
                });
            }
            if (o.format) {
                $(this).css({
                    'margin' : '0 0 5px 0',
                    'padding' : '0',
                    'max-width' : width
                }).attr('align', 'middle');
                $(this).wrap('<div align="center"></div>')
            }
        });
    });
}