var flag=false; 
function DrawImage(ImgD,wi,he){ 
var w=wi;
var h=he;
var w1;
var h1;
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0){ 
flag=true; 
if(image.width/image.height>= h/w){ 

if(image.width>w){ 
w1=w; 
h1=(image.height*w)/image.width;

if (h1>h)
{
w1=w*(h/h1);
h1=h;
}
ImgD.width=w1;
ImgD.height=h1;

}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
/*ImgD.alt="bigpic" */ 
} 
else{ 
if(image.height>h){ 
h1=h; 
w1=(image.width*h)/image.height; 

if (w1>w)
{
h1=h*(w/w1);
w1=w;
}
ImgD.width=w1; 
ImgD.height=h1; 

}else{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
/*ImgD.alt="bigpic" */ 
} 
} 
} 
