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