        function DrawImage(ImgD, iwidth, iheight)
        {
            var image=new Image();
            image.src = ImgD.src;
            
            var Width;
            var Height;
            
            Width = image.width;
            Height = image.height;

            if (image.width > 0 && image.height > 0)
            {
                if (image.width / image.height >= iwidth / iheight) 
                {
                    ImgD.width  = iwidth;
                    ImgD.height = Height * iwidth / Width;
                }
                else
                {
                    ImgD.height = iheight;
                    ImgD.width = Width * iheight / Height;
                }
            }
        } 