﻿
function ImageZoom(ImgD,maxWidth,maxHeight)
{
    var flag=false;
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0)
    {
        flag=true;
        if(image.width/image.height>= maxWidth/maxHeight)
        {
            if(image.width>maxWidth)
            {
                ImgD.width=maxWidth;
                ImgD.height=(image.height*maxWidth)/image.width;
            }
            else
            {
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
//            ImgD.alt=image.width+"x"+image.height;
        }
        else
        {
            if(image.height>maxHeight)
            {
                ImgD.height=maxHeight;
                ImgD.width=(image.width*maxHeight)/image.height;
            }
            else
            {
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
//            ImgD.alt=image.width+"x"+image.height;
        }
    }
}
