var flag=false; 
function DrawImage(ImgD,wt,ht){ 
//wt:设定图片显示宽度
//ht:设定图片显示高度
    var image=new Image(); 
    var xwidth=wt;
    var xheight=ht;
    var img;
    image.src=ImgD.src; 
    iwidth=image.width;
    iheight=image.height;
    if (image.width>0 && image.height>0){ 
       flag=true; 
       if (iwidth/iheight>= xwidth/xheight){ 
          if (image.width>xwidth){ 
             ImgD.width=xwidth; 
             ImgD.height=(iheight*xwidth/iwidth); 
          }else{ 
             ImgD.width=image.width; 
             ImgD.height=image.height; 
          }             
          ImgD.alt=image.width+"x"+image.height; 
       }else{
         if (image.height>xheight) { 
            ImgD.height=xheight; 
            ImgD.width=(iwidth*xheight/iheight); 
         }else{ 
            ImgD.width=xwidth; 
            ImgD.height=xheight; 
        }
        ImgD.alt=image.width+"x"+image.height; 
       }
    } 
} 

