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