var MAX_WIDTH = 700;

function resize_images()
{
	var imageCount = document.images.length;
	documentImages = document.images;
	for (i=0; i <imageCount; i++) 
	{
		if (documentImages[i].id == "contents" || documentImages[i].id=="photo")
        {
			if (documentImages[i].width > MAX_WIDTH)
            {
                documentImages[i].width = MAX_WIDTH;
            }
        } else if (documentImages[i].id == "goods") {

			if (documentImages[i].width >= documentImages[i].height 
					&& documentImages[i].width > 340)
            {
                documentImages[i].width = 340;
            } else if (documentImages[i].width < documentImages[i].height 
					&& documentImages[i].height > 340 )
			{
                documentImages[i].height = 340;
            }
        } 


	}

	//utfpatch();
}

var MAX_WIDTH2 = 680;

function resize_images2()
{
	var imageCount = document.images.length;
	documentImages = document.images;
	for (i=0; i <imageCount; i++) 
	{
		if (documentImages[i].id == "contents" || documentImages[i].id=="photo")
        {
			if (documentImages[i].width > MAX_WIDTH2)
            {
                documentImages[i].width = MAX_WIDTH2;
            }
        } else if (documentImages[i].id == "goods") {

			if (documentImages[i].width >= documentImages[i].height 
					&& documentImages[i].width > 340)
            {
                documentImages[i].width = 340;
            } else if (documentImages[i].width < documentImages[i].height 
					&& documentImages[i].height > 340 )
			{
                documentImages[i].height = 340;
            }
        } 


	}

	//utfpatch();
}

function resize_images3()
{
	var imageCount = document.images.length;
	documentImages = document.images;
	for (i=0; i <imageCount; i++) 
	{
		if (documentImages[i].id == "contents" || documentImages[i].id=="photo")
        {
			if (documentImages[i].width > MAX_WIDTH)
            {
                documentImages[i].width = MAX_WIDTH;
            }
        } else if (documentImages[i].id == "goods") {

			if (documentImages[i].width >= documentImages[i].height 
					&& documentImages[i].width > 340)
            {
                documentImages[i].width = 340;
            } else if (documentImages[i].width < documentImages[i].height 
					&& documentImages[i].height > 340 )
			{
                documentImages[i].height = 340;
            }
        }  else {
			if (documentImages[i].width > MAX_WIDTH2)
            {
                documentImages[i].width = MAX_WIDTH2;
            }
		}
	}
}

// ÀÌ¹ÌÁö Å©±â¸¦ °è»êÇÏ±â ÁÁ°Ô ÇÏ±â À§ÇØ ¸Þ¸ð¸®¿¡ ·Îµå½ÃÄÑ³õÀ¸·Á°í 
// image°´Ã¼ »ý¼ºÇÏ°í, ÀÌ¸§À» ÁÖ¾ú´Ù. ¾È ±×·¯¸é, ÀÌ¹ÌÁö ·ÎµåµÇ±â Àü °è»êÄ¡°¡ ³ª¿Â´Ù.
/*
<img onclick="javascript:view_original_image(this);" style="cursor:hand" 
    src="http://photo-media.hanmail.net/daum/cartoon/200408/16/d2m.jpg">
*/

var imageWindow;

function view_original_image(obj) 
	{
		var nWnWidth, nWnHeight;
		var strUrl;

		strUrl = "common.popup.image.scrn?image=" + obj.src; 
		
		nWnWidth = (window.screen.width / 2) - (122 * 10);
		nWnHeight = (window.screen.height / 2) - (27 + 50);

		imageWindow = window.open(strUrl, 
					"imageViewer", 
					"width=100, height=100, left=" + nWnWidth + ", top=" + nWnHeight + ", screenX=" + nWnWidth + ", screenY=" + nWnHeight + ", status=no, toolbar=no, scrollbars=1, resizable=1");
		imageWindow.focus();
	}

function utfpatch()
{
	for (i=0;i<document.images.length;i++)
		if (!document.images[i].complete)
			document.images[i].src = toUtf(document.images[i].src);
}
	
function toUtf(strUrl)
{
	var p1,p2;
	p1 = strUrl.lastIndexOf("/");
	if (p1 == -1)
		p1 = 0;
	p2 = strUrl.lastIndexOf(".");
	if (p2 == -1)
		return strUrl;
	return strUrl.substring(0,p1+1) + escape(strUrl.substring(p1+1,p2)) + strUrl.substring(p2,strUrl.length);
}

function checkImgFormat(imgPath) {
	var len = imgPath.length;
	var sFormat = imgPath.substring(len-4);

	if ( sFormat == ".PNG" ||
		sFormat == ".JPG" ||
		sFormat == ".BMP" ||
		sFormat == ".GIF" ||
		sFormat == ".png" ||
		sFormat == ".bmp" ||
		sFormat == ".gif" ||
		sFormat == ".jpg" ) {

		document.previewImg.src = imgPath;

	} else {
		if ( imgPath != "" ) {
			alert("Áö¿øÇÏÁö ¾Ê´Â ÆÄÀÏÇü½ÄÀÔ´Ï´Ù. »çÁøÀº jpg,gif,bmp,png Æ÷¸ËÀ» Áö¿øÇÕ´Ï´Ù. ÆÄÀÏÀ» ´Ù½Ã ¼±ÅÃÇØÁÖ¼¼¿ä.");
			return
		}
	}
}

// °¢ ±â°£°Ë»ö ÅØ½ºÆ® ¹Ú½º ÃÊ±âÈ­
function init_date()
{
/*	if (document.all.start_date != null)
	{
		var today = new Date();
		var yyyy = today.getYear();
		var mm = today.getMonth() + 1;
		var mmStr = "";
		if (mm < 10)
			mmStr = "0" + mm;
		var dd = today.getDate();
		document.all.start_date.value = document.all.end_date.value = yyyy + mmStr + dd;
	}*/
}
