/*@cc_on
@if (@_win32 && @_jscript_version>4)

function calc_size(orgSize, targetSize) {
    var orgHeight = orgSize.height;
    var orgWidth = orgSize.width;
    var newHeight, newWidth;

    if (targetSize.height > targetSize.width) {
        if (orgHeight > targetSize.height) {
            newHeight = targetSize.height;
            newWidth = orgWidth * targetSize.height / orgHeight;
            if (newWidth > targetSize.width) {
                newWidth = targetSize.width;
                newHeight = orgHeight * targetSize.width / orgWidth;
            }
        } else {
            newHeight = orgHeight;
            newWidth = orgWidth;
            if (newWidth > targetSize.width) {
                newWidth = targetSize.width;
                newHeight = orgHeight * targetSize.width / orgWidth;
            }
        }
    } else {
        if (orgWidth > targetSize.width) {
            newWidth = targetSize.width;
            newHeight = orgHeight * targetSize.width / orgWidth;
            if (newHeight > targetSize.height) {
                newHeight = targetSize.height;
                newWidth = orgWidth * targetSize.height / orgHeight;
            }
        } else {
            newHeight = orgHeight;
            newWidth = orgWidth;
            if (newHeight > targetSize.height) {
                newHeight = targetSize.height;
                newWidth = orgWidth * targetSize.height / orgHeight;
            }
        }
    }

	if (newWidth < 1)
		newWidth = 1;

	if (newHeight < 1)
		newHeight = 1;

    return {width:newWidth, height:newHeight};
}

$(function(){
  $('img[max-width]').each(function(){
    var maxw = $(this).attr('max-width').replace('px', '');
    var maxh = $(this).attr('max-height').replace('px', '');
    var size = calc_size(this, {width:maxw, height:maxh});
    $(this).css({width:size.width + 'px', height:size.height + 'px'})
  });
});

@end @*/
