<!--
/* vim: set tabstop=4 shiftwidth=4 syntax=javascript: */
var baseOpenWinTarget	= "Debon";

function openWin(uri, target, width, height, scrollbars, resize, pos)
{
	var xy_pos = "";
	if (pos)
	{
		xy_pos  = ",left=" + (Math.round(screen.width/2) - Math.round(width/2));
		xy_pos += ",top="  + (Math.round(screen.height/2) - Math.round((height + 80)/2));
	}
	if (typeof(target) == "string") target = target + baseOpenWinTarget;
	var remoteNewWin = window.open(uri, target, "width=" + width +
				",height=" + height +
				",scrollbars=" + scrollbars +
				",resizable=" + resize +
				xy_pos +
				",toolbar=no,location=no" +
				",directories=no,menubar=no,status=yes");
	remoteNewWin.focus();
	return remoteNewWin;
}

function alertWindow (form, title, message)
{
	var url = "/apps/tools/alert.php";

	// ÀÔ·Â ¿À·ù½Ã º¸¿©ÁÙ °æ°íÃ¢
	if (form != false)
	{
		form.focus();
	}
	// ADD GARAM 20060713
	message	= (title != "") ? title + " : " + message : message;
	alert(message);	return;
	// SKIP!
	var new_message = "";
	for (var i = 0; i < message.length; i++)
	{
		// "\n" -> "<BR>"
		if (message.charAt(i) == "\n")
		{
			new_message = new_message + "<BR>";
		}
		else
		{
			new_message = new_message + message.charAt(i);
		}
	}
	var alert_window = openWin(url + "?" + "&title=" + title +
								"&message=" + new_message,
								"", 100, 50, "no", "yes", true);
}

function lengthByte (str)
{
	// IE, ±ÛÀÚ¼ö ÃøÁ¤½Ã 2byte ¹®ÀÚ °¨¾È
	var len = str.length;
	for (var i=0; i<str.length; i++)
	{
		if (str.charCodeAt(i) > 255) len++;
	}
	return len;
}

function substringByte (str, byte)
{
	// IE, 2byte ¹®ÀÚ¸¦ °¨¾ÈÇÏ¿© ¹®ÀÚ¿­ ºÎºÐ ÃßÃâ
	var len = 0;
	var new_str = "";
	for (var i=0; i<str.length; i++)
	{
		len++;
		if (str.charCodeAt(i) > 255) len++;
		if (byte < len) return new_str;
		else new_str += str.charAt(i);
	}
	return new_str;
}
function firstFieldFocus (form)
{
	// ÇØ´ç ÀÔ·Â¾ç½ÄÀÇ Ã¹¹øÂ° TEXT Ç×¸ñ ¶Ç´Â PASSWORD Ç×¸ñ¿¡
	// ÀÚµ¿À¸·Î Æ÷Ä¿½º¸¦ ³Ö¾îÁÖ´Â ÇÔ¼ö
	if (typeof(form) == 'undefined') return;
	var count = form.elements.length;
	for (var i=0; i<count; i++)
	{
    	if (form.elements[i].type == "text" || form.elements[i].type == "password")
		{
			if (form.elements[i].value.length == 0) form.elements[i].focus();
			return;
		}
	}
}

function getSelected (select, mode)
{
	// ÇöÀç ¼±ÅÃµÈ SELECT Ç×¸ñÀÇ ¼±ÅÃ°ªÀ» ¾ò´Â ÇÔ¼ö
	if (select == null) return null;
	if (mode == "index") return select.selectedIndex;
	else if (mode == "value") return select.options[select.selectedIndex].value;
	else if (mode == "text") return select.options[select.selectedIndex].text;
}
function getSelectedValue (select) { return getSelected(select, "value"); }
function getSelectedText (select) { return getSelected(select, "text"); }
function getSelectedIndex (select) { return getSelected(select, "index"); }

function setSelected (select, mode, value)
{
	// SELECT Ç×¸ñÁß Æ¯Á¤ OPTION Ç×¸ñÀ» ±âº»ÀûÀ¸·Î ¼±ÅÃ(SELECTED)µÇµµ·Ï ÇÏ´Â ÇÔ¼ö
	if (select == null) return false;
	if (mode == "index")
	{
		select.selectedIndex = value;
		return true;
	}
	else
	{
		for (var i=0; i<select.options.length; i++)
		{
			if ((mode == "value" && select.options[i].value == value) ||
				 (mode == "text" && select.options[i].text == value))
			{
				select.selectedIndex = i;
				return true;
			}
		}
	}
	return false;
}
function setSelectedByValue (select, value) { return setSelected(select, "value", value); }
function setSelectedByText (select, value) { return setSelected(select, "text", value); }
function setSelectedByIndex (select, value) { return setSelected(select, "index", value); }

function checkboxCheck(form, mode)
{
	for (var i=0; i<form.elements.length; i++)
	{
		var e = form.elements[i];
		if (e.type == "checkbox")
		{
			if (mode == 1) e.checked = true;
			if (mode == 2) e.checked = false;
			if (mode == 3) e.checked = !e.checked;
		}
	}
}
function checkboxAllCheck (form) { checkboxCheck(form, 1); }
function checkboxAllUnCheck (form) { checkboxCheck(form, 2); }
function checkboxReverseCheck (form) { checkboxCheck(form, 3); }


/* select ¿¡¼­ option Ãß°¡ 
 * form		=> document.FORM_NAME.SELECT_NAME
 * getTexts	=> option TEXT
 * getVals	=> option VALUE
*/
function addSelectOption (form, getVals, getTexts)
{
	var len = form.options.length;
    form.options[len]    = new Option(getTexts, getVals);
}
/* select ¿¡¼­ option Á¦°Å
 * form		=> document.FORM_NAME.SELECT_NAME
 * getFlag	=> ÃÖ¼Ò ´ÜÀ§¸¦ »èÁ¦ ÇÒ°ÍÀÎ°¡? °ªÀÌ ÀÖÀ¸¸é ºÒ°¡´É
*/
function removeSelectOption (form, getFlag)
{
	var Lens = form.length;
	if (getFlag)
	{
		if (Lens < 2)
		{
			alertWindow("", "", "ÃÖ¼Ò °ªÀº »èÁ¦ ÇÒ¼ö ¾ø½À´Ï´Ù.");
			return false;
		}
	}
    if (form.selectedIndex >= 0) form.options.remove(form.selectedIndex);
    if (form.options.length > 0) form.selectedIndex = 0;
}
function removeSelectOptionAll (form, minIndex)
{
	for (var i=form.options.length-1; i>=minIndex; i--)
	{
		form.options.remove(i);
	}
}
function removeSelectOptionByValue (form, value)
{
	for (var i=form.options.length-1; i>=0; i--)
	{
		if (form.options[i].value == value)
		{
			form.options.remove(i);
			if (form.options.length > 0) form.selectedIndex = 0;
		}
	}
}
function objectWriter (getID, obj_type, id, src, width, height, transparent)
{
	if (transparent == '' || typeof transparent == 'undefined') transparent = false;
	obj = [];
	switch (obj_type)
	{
		case "flash":
				obj[obj.length] = "<OBJECT ID='" + id + "' CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' WIDTH='" + width + "' HEIGHT='" + height + "'>";
				obj[obj.length] = "<PARAM NAME='movie' VALUE='" + src + "'>";
				obj[obj.length] = "<PARAM NAME='menu' VALUE='false'>";
				if (transparent === true) obj[obj.length] = "<PARAM NAME='wmode' VALUE='transparent'>";
				obj[obj.length] = "<EMBED SRC='" + src + "' QUALITY='high' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' TYPE='application/x-shockwave-flash' WIDTH='" + width + "' HEIGHT='" + height + "'></EMBED>";
				obj[obj.length] = "</OBJECT>";
				obj = obj.join('\n');
		break;
	}

	if (getID != '' && typeof getID != 'undefined') getID.innerHTML=obj;
	else document.write(obj);
}

function openPopupHtml (view)
{
	var width	= 0;
	var height	= 0;
	var scroll	= "no";
	switch (view)
	{
		case "favor_user"	:	width	= 550;	height	= 605;	break;	// ±¸¸ÅÈ¸¿ø µî±Þº° ÇýÅÃ
		case "guide_saller"	:	width	= 550;	height	= 730;	break;	// È­¿ø¾÷Ã¼ °¡ÀÔ½Ã ÁÖÀÇ»çÇ×
		case "policy"		:	width	= 700;	height	= 730;	break;	// °³ÀÎº¸È£Á¤Ã¥
		case "day_counting"	:	width	= 500;	height	= 404;	break;	// ³¯Â¥°è»ê
		case "mail_get_refusal"	:	width	= 600;	height	= 350;	break;	// ÀÌ¸ÞÀÏ ¹«´Ü ¼öÁý°ÅºÎ
		case "guide_rollsc"		:	width	= 620;	height	= 700;	scroll	= "yes";	break;	// ·Ñ½ºÅ©¸° ¿¹Á¦ ÆË¾÷
		case "photo_manual"		:	width	= 670;	height	= 700;	scroll	= "yes";	break;	// »çÁø¿ë·®ÁÙÀÌ´Â ÇÃ·Î±×·¥ ¸Þ´º¾ó
	}
	if (width > 0)	return openWin("/apps/tools/popup_html.php?view=" + view, "_Pop_" + view, width, height, scroll, "no", true);
	return;
}

// ÄíÅ° °ü·Ã °Ë»ç
function getCookie (name)
{
    var nameOfCookie = name + "=";
    var x = 0;
    while ( x <= document.cookie.length )
    {
        var y = (x+nameOfCookie.length);
        if ( document.cookie.substring( x, y ) == nameOfCookie )
        {
            if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
            endOfCookie = document.cookie.length;
            return unescape( document.cookie.substring( y, endOfCookie ) );
        }
        x = document.cookie.indexOf(" ", x) + 1;
        if ( x == 0 ) break;
    }
    return "";
}
// ÄíÅ° ¼ÂÆÃ
function setCookie (name, value, expiredays)
{
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) +
						"; path=/; expires=" + todayDate.toGMTString() + ";"
}


// ·Ñ¿À¹ö ÀÌ¹ÌÁöÃ³¸®
function MM_swapImgRestore () { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages () { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj (n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage () { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getChangeDateTerm (getTerm, sobj, eobj)
{
	if (getTerm == "all")
	{
		sobj.value = "";
		eobj.value = "";
		document.all['hiddenall'].value = 'all';
	}
	else
	{
		getTerm			= parseInt(getTerm, 10);
		var getNow		= new Date();
		var newDate		= new Date();
		newDate.setDate(getNow.getDate() - getTerm);
		var nowMonth	= getNow.getMonth() + 1;
		var newMonth	= newDate.getMonth() + 1;
		var nowDay		= getNow.getDate();
		var newDay		= newDate.getDate();
		nowMonth		= (parseInt(nowMonth, 10) < 10) ? "0" + nowMonth : nowMonth;
		newMonth		= (parseInt(newMonth, 10) < 10) ? "0" + newMonth : newMonth;
		newDay			= (parseInt(newDay, 10) < 10) ? "0" + newDay : newDay;
		nowDay			= (parseInt(nowDay, 10) < 10) ? "0" + nowDay : nowDay;

		sobj.value = newDate.getYear() + "-" + newMonth + "-" + newDay;
		eobj.value = getNow.getYear() + "-" + nowMonth + "-" + nowDay;
		document.all['hiddenall'].value = '';
	}
}

//-->