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

