var  flag=false;

function DrawImage(ImgD, style)
{
    var maxW = 120, maxH = 120;
    if (style == 1)
    {
        var maxW = 102;
        var maxH = 104;
    }

    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0)
    {
        flag = true;
        if (image.width / image.height >= maxW / maxH)
        {
            if (image.width > maxW)
            {
                ImgD.width = maxW;
                ImgD.height = (image.height * maxW) / image.width;
            }
            else
            {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
            //ImgD.alt=image.width+"กม"+image.height;
        }
        else
        {
            if (image.height > maxH)
            {
                ImgD.height = maxH;
                ImgD.width = (image.width * maxH) / image.height;
            }
            else
            {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
            // ImgD.alt=image.width+"กม"+image.height;
        }
    }
}
