function DrawImage(ImgD,w,h){ 
	var image=new Image();
	image.src=ImgD.src; 

	var oldwidth = image.width;
	var oldheight = image.height;

	var tempwidth;
	var tempheight;
	
	if(oldwidth > w){
		tempwidth = w;
		tempheight =  tempwidth*oldheight/oldwidth;
		oldwidth = tempwidth;
		oldheight = tempheight;
	}

	if(oldheight > h){
		tempheight = h;
		tempwidth =  tempheight*oldwidth/oldheight;
		oldheight = tempheight;
		oldwidth = tempwidth;
	}

	ImgD.width = oldwidth;
	ImgD.height = oldheight;
} 