function DrawImage(ImgD,widths,heights){ 
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= widths/heights){
			if(image.width>widths){  
				ImgD.width=widths;
				ImgD.height=(image.height*widths)/image.width;
			}else{
				ImgD.width=image.width;  
				ImgD.height=image.height;
			}
		}
		else{
			if(image.height>heights){  
				ImgD.height=heights;
				ImgD.width=(image.width*heights)/image.height;     
			}else{
				ImgD.width=image.width;  
				ImgD.height=image.height;
			}
		}
    }
} 