//ÀÌ¹ÌÁö ¸®»çÀÌÁî
function adjustImage(target_img,maxW)
{
	var newX, newY;
	var newHeight, newWidth;
	var newImg;

	var maxWidth = maxW; // °¡·Î ÃÖ´ë Å©±â´Â

	newImg = new Image();
	newImg.src = target_img.src;
	imgw = newImg.width;
	imgh = newImg.height;
	var maxHeight = 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;
}

//ÀÌ¹ÌÁö ¸®»çÀÌÁî
function adjustImage2(target_img,maxW,maxH)
{
	var newX, newY;
	var newHeight, newWidth;
	var newImg;

	var maxWidth = maxW; // °¡·Î ÃÖ´ë Å©±â´Â
	var maxHeight = maxH; // ¼¼·Î ÃÖ´ë Å©±â

	newImg = new Image();
	newImg.src = target_img.src;
	target_img.onload = null;
	imgw = newImg.width;
	imgh = newImg.height;

	if(imgw ==0) imgw = maxW;
	if(imgh ==0) imgh = maxH;

	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;
	}

	
	target_img.src = newImg.src;
	target_img.width = newWidth;
	target_img.height = newHeight;
}

//ÀÌ¹ÌÁö ¸®»çÀÌÁî
function adjustImage3(target_img,maxW,maxH)
{
	var newX, newY;
	var newHeight, newWidth;
	var newImg;

	var maxWidth = maxW; // °¡·Î ÃÖ´ë Å©±â´Â
	var maxHeight = maxH; // ¼¼·Î ÃÖ´ë Å©±â

	newImg = new Image();
	newImg.src = target_img.src;
	target_img.onload = null;
	imgw = newImg.width;
	imgh = newImg.height;

	if(imgw ==0) imgw = maxW;
	if(imgh ==0) imgh = maxH;

	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;
	}

	
	target_img.src = newImg.src;
	target_img.width = newWidth;
	target_img.height = newHeight;

	target_img.style.display = "block";
}