
 function func_adjustimage(target_img,w,h)
 {
			var w;
			var h;
			var newX;
			var newY;
			var newHeight;
			var newWidth;
			var maxWidth = w;
			var maxHeight = h;
			var newImg = new Image();
			newImg.src = target_img.src;
			imgw = newImg.width;
			imgh = newImg.height;
			if (imgw > maxWidth || imgh > maxHeight){
				 if (imgw > imgh){
						if (imgw > maxWidth)
							 newWidth = maxWidth;
						else
							 newWidth = imgw;
						newHeight = Math.round((imgh * newWidth) / imgw);
				 }else{
						if (imgh > maxHeight)
							 newHeight = maxHeight;
						else
							 newHeight = imgh;
						newWidth = Math.round((imgw * newHeight) / imgh);
				 }
			}else{
				 newWidth = imgw;
				 newHeight = imgh;
			}
			 newX = maxWidth / 2 - newWidth / 2;
			 newY = maxHeight / 2 - newHeight / 2;
			 target_img.onload = null;
			 target_img.src = newImg.src;
			 target_img.width = newWidth;
			 target_img.height = newHeight;
	 }