  var   flag=false;   
  function   DrawImage(ImgD,imgw,imgh){   
        var   image=new   Image();   
        image.src=ImgD.src;   
        if(image.width>0   &&   image.height>0){   
          flag=true;   
          if(image.width/image.height>=   imgw/imgh){   
            if(image.width>imgw){       
            ImgD.width=imgw;   
            ImgD.height=(image.height*imgw)/image.width;   
            }else{   
            ImgD.width=image.width;       
            ImgD.height=image.height;   
            }   
            ImgD.alt="";   
            }   
          else{   
            if(image.height>imgh){       
            ImgD.height=imgh;   
            ImgD.width=(image.width*imgh)/image.height;             
            }else{   
            ImgD.width=image.width;       
            ImgD.height=image.height;   
            }   
            ImgD.alt="";   
            }   
          }   
  }     
