﻿var flag = false;
function ImgZoom(Img, MaxW, MaxH) {
    var image = new Image();
    image.src = Img.src;
    if (image.width > 0 && image.height > 0) {
        flag = true;
        if (image.width / image.height >= MaxW / MaxH) {
            if (image.width > MaxW) {
                Img.width = MaxW;
                Img.height = (image.height * MaxW) / image.width;
            } else {
                Img.width = image.width;
                Img.height = image.height;
            }
        }
        else {
            if (image.height > MaxH) {
                Img.height = MaxH;
                Img.width = (image.width * MaxH) / image.height;
            } else {
                Img.width = image.width;
                Img.height = image.height;
            }
        }
    }
}

