$(document).ready(function () {

	$('.post-content img').each(function () {
		resizeImage($(this));
	});

	$('.post-content img').load(function () {
		resizeImage($(this));
	});
});

function resizeImage($img) {
	var width = $img.width();
	var maxWidth = 520;
	if (width > maxWidth) {
		var scale = maxWidth / width;
        width = width * scale;
        var height = $img.height();
        height = height * scale;

        $img.css('width', width + 'px');
        $img.css('height', height + 'px');
    }
}
