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