//function bluring(){if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();}document.onfocusin=bluring;  // FOCUS Á¦°Å
// ºÎºÐ ¿¡·¯³ª¼­ ÀÏ´Ü »­.
// ÄíÅ° ¾²±â
function setCookie( name, value, expiredays ) {
  var todayDate = new Date();
  todayDate.setDate( todayDate.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}
// ÄíÅ° ÀÐ±â
function getCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen){
		var j = i + alen;
		if(document.cookie.substring(i, j) == arg)return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0) break;
	}
	return null;
}
function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf(";", offset);
	if(endstr == -1)endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

/*========================
		ÆäÀÌÁö ÀÌµ¿¿¡ °ü·ÃµÈ ÇÔ¼ö
========================*/

// Ä«Å×°í¸® ÀÌµ¿
function goShop(id)
{//id´Â ID_DEPTH(1ÀÚ¸®) + ID_CODE(³ª¸ÓÁö)
	var ID_DEPTH = id.slice(0,1);
	var ID_CODE = id.slice(1);

	switch(ID_DEPTH)
	{
		case "1":		fileName	= "/item/ctg_list_l.php";		break;
		case "2":		fileName	= "/item/ctg_list_s.php";		break;		// ÁßÄ«Å×°í¸®°¡ ÀÖ´Â°æ¿ì ¿©±â¸¦ ¼öÁ¤
		case "3":		fileName	= "/item/ctg_list_s.php";		break;
	}
	self.location = fileName + "?ctg=" + ID_CODE;
}

//¾ÆÀÌ²ÞÅÍ¿Í ´Ù¸¥ ¼îÇÎ¸ô ¹®Á¦¹ß»ý ¹æÁö¸¦ À§ÇÑ ¾ÆÀÌ²ÞÅÍ¿ë
function goShop_icmc(id)
{//id´Â ID_DEPTH(1ÀÚ¸®) + ID_CODE(³ª¸ÓÁö)
	var ID_DEPTH = id.slice(0,1);
	var ID_CODE = id.slice(1);

	switch(ID_DEPTH)
	{
		case "1":		fileName	= "/item/ctg_list_l.php";		break;
		case "2":		fileName	= "/item/ctg_list_m.php";		break;		// ÁßÄ«Å×°í¸®°¡ ÀÖ´Â°æ¿ì ¿©±â¸¦ ¼öÁ¤
		case "3":		fileName	= "/item/ctg_list_s.php";		break;
	}
	self.location = fileName + "?ctg=" + ID_CODE;
}

function goShop_gift(id)
{//id´Â ID_DEPTH(1ÀÚ¸®) + ID_CODE(³ª¸ÓÁö)
	var ID_DEPTH = id.slice(0,1);
	var ID_CODE = id.slice(1);

	switch(ID_DEPTH)
	{
		case "1":		fileName	= "/gift/ctg_list_l.php";		break;
		case "2":		fileName	= "/gift/ctg_list_s.php";		break;		// ÁßÄ«Å×°í¸®°¡ ÀÖ´Â°æ¿ì ¿©±â¸¦ ¼öÁ¤
		case "3":		fileName	= "/gift/ctg_list_s.php";		break;
	}
	self.location = fileName + "?ctg=" + ID_CODE;
}

/*========================
»óÇ°ÀÌ¹ÌÁö ¾øÀ»½Ã º¸¿©ÁÖ´Â ÀÌ¹ÌÁö
»ç¿ë¹ý : <img src='xxx' onError='noPic(this)'>
========================*/
function noPic(img)
{
	img.src = "/shops/common/images/_nopic.jpg";
}



function noPic_m(img)	//»ó¼¼º¸±â
{
	img.src = "/shops/common/images/_nopic_m.jpg";
}

function item_view(product_id, event)
{
	// self.location = "/item/item_view.php?itemid=" + product_id;
	// mod_rewrite ÀÌ¿ë

	if(event == "Y"){
		event = '&event_yn='+event;
	}else{
        event = '';
    }
    self.location = "/item/item_view.php?itemid=" + product_id + event;
}

function item_view_gift(product_id)
{
	self.location = "/gift/" + product_id;
}

/*========================
ÇöÀçÀÇ URL¿¡¼­ GET º¯¼ö¸¦ Ãß°¡(º¯°æ)ÇÏ¿©
±× ÆäÀÌÁö·Î º¯°æÇÑ´Ù.
names : º¯¼ö¸í, values : °ª.
========================*/
function useful_url(names,values)
{
	cUrl = new String(document.location);
	pattern = new RegExp(names+"=");
	results = cUrl.match(pattern);
		if (results==null)
		{
			res = cUrl.indexOf("?");
			joints = (res>0)?"&":"?";
			rets = cUrl + joints + names + "=" + values;
		}
		else
		{
			var eExp = new RegExp(names+"=(.*?)(\&|$)");
			var rets = cUrl.replace(eExp, names+"="+values+"&");
		}
	rets = new String(rets);
	rets = rets.replace(/\&\&/, "&");
	rets = rets.replace(/\&$/, "");
	self.location = rets;
}

function isNumber (){
if ((event.keyCode<48)||(event.keyCode>57)){event.returnValue=false;}
}

/*========================
	Àå¹Ù±¸´Ï¿¡ ³Ö´Â´Ù. _1Àº Àå¹Ù±¸´ÏÆäÀÌÁö³» °ü½É»óÇ°À» Àå¹Ù±¸´Ï¿¡ ´ãÀ»¶§
	f : Æû ÀÌ¸§.
========================*/
function intoCart(f, event)
{
    if(event == "Y"){
        event = "?event_yn=Y"
    }else{
        event = ""
    }
	form = eval("document."+f);
	form.action = "/order/cart_process_redirect.php"+event;
	form.target = "process";
	form.whatto.value = "ADD";
	form.submit();
}
function intoCart_1(f)
{
	form = eval("document."+f);
	form.target = "process";
	form.whatto.value = "ADD_CART";
	form.submit();
}

/*========================
	Àå¹Ù±¸´Ï¿¡ ³Ö´Â´Ù. (¹Ù·Î±¸¸ÅÀÏ°æ¿ì)
	f : Æû ÀÌ¸§.
========================*/
function intoBuy(f)
{
	form = eval("document."+f);
	form.action = "/order/cart_process_redirect.php";
	form.target = "process";
	form.whatto.value = "BUY_ADD";
	form.submit();
}

/*========================
	°ü½É»óÇ°¿¡ ³Ö´Â´Ù. _1Àº Àå¹Ù±¸³»ÆäÀÌÁö³» °ü½É»óÇ°À» ´ãÀ»¶§
	f : Æû ÀÌ¸§.
========================*/
function intoWishlist(f)
{

	form = eval("document."+f);
	form.action = "/mypage/mypage_wishlist_process_redirect.php";
	form.target = "process";
	form.whatto.value = "ADD";
	form.submit();
}
function intoWishlist_1(f)
{
	form = eval("document."+f);
	form.action = "/mypage/mypage_wishlist_process_redirect.php";
	form.target = "process";
	form.whatto.value = "ADD_CART";
	form.submit();
}
/*========================
	Àå¹Ù±¸´Ï»óÇ° ¼öÁ¤/»èÁ¦
	f : Æû ÀÌ¸§. id_code : »óÇ°ÄÚµå, row : index_³Ñ¹ö, how :[m]¼öÁ¤[d]»èÁ¦
========================*/
function modifyCart(f,id_code,row,how)
{
	form = eval("document."+f);
	form.action = "/order/cart_process_redirect.php";
	//form.target = "process";
	form.whatto.value=(how=="m")?"MODIFY":"DELETE";
	form.id_code.value=id_code;
	form.row.value=row;

	if(row<0 && id_code==""){if(!confirm("Àå¹Ù±¸´ÏÀÇ ¸ðµç »óÇ°À» ºñ¿ì½Ã°Ú½À´Ï±î?")){return false;}	}
	form.submit();
}

function intoLogin(how,postscript,popup_opt)
{

	if (how==-1)	// ·Î±×¾Æ¿ôÀÇ °æ¿ì
	{
		if (confirm("·Î±×¾Æ¿ô ÇÏ½Ã°Ú½À´Ï±î?")){location = "/cust/cust_process_redirect.php?pmode=logout";}
	}
	else if (how==2) // ÆË¾÷·Î±×ÀÎÀÇ °æ¿ì
	{
		window.open('/cust/cust_login.php?win=popup&ps=' + escape(postscript), 'login_p', popup_opt);
	}
	else			// ±âº» ·Î±×ÀÎÆäÀÌÁö ÀÌµ¿
	{
		location = "/cust/cust_login.php?r_uri="+r_uri;
	}
}

function intoSignin()
{
		location = "/cust/cust_signin01.php";
}

/*----------------------------------------------------------------------------------------------
* °ü¸®ÀÚ - ÁÖ¼ÒÃ£±â¸¦ ¶ç¿î´Ù.
* fn	: Æû ³×ÀÓ
* zf	: ¿ìÆí¹øÈ£ ÇÊµå ³×ÀÓ
* ff	: ÀüÃ¼ ÁÖ¼Ò ÇÊµå ³×ÀÓ
* cf	: ½Ã/µµ ÇÊµå ³×ÀÓ
* gf	: ±¸/±º ÇÊµå ³×ÀÓ
* df	: µ¿ ÇÊµå ³×ÀÓ
* ef	: ³ª¸ÓÁö ÁÖ¼Ò ÇÊµå ³×ÀÓ
*----------------------------------------------------------------------------------------------*/
function openAddress(fn,zf,ff,cf,gf,df,ef,zc,tb) {
window.open("/etc/search_address.php?fn="+fn+"&zf="+zf+"&ff="+ff+"&cf="+cf+"&gf="+gf+"&df="+df+"&ef="+ef+"&zc="+zc+"&tb="+tb, "", "width=447, height=225, scrollbars=1");
}

function trim(str) // ¸»±×´ë·Î Æ®¸²
	{var reg = /\s+/g; return str.replace(reg,'');}

function toUpper(obj)
	{	obj.value = obj.value.toUpperCase();}


function chkItemFind(form)
{
//	form = document.item_find;
	keyword = trim(form.q.value);
	if (keyword.length<2)
	{
		alert('°Ë»ö¾î°¡ ¾ø°Å³ª ³Ê¹« Âª½À´Ï´Ù.'); form.q.value=""; form.q.focus(); return false;
	}
}

function openItemFindDetail()
{
	window.open("/item/item_find_detail.php", "findME", "width=600, height=316");
}
function openItemFindDetail1()
{
	window.open("/item/item_find_detail.php", "findME", "width=555, height=280");
}

// elementÀÇ disabled Á¦¾î
function setDisabled(str, how) // strÀº ,·Î ±¸ºÐµÈ ÇÊµå ¾ÆÀÌµð, how´Â enableÀÎÁö disableÀÎÁö(1,0)
{
	howto = (how==1)?false:true;
	splitString = str.split(",");
	for (i=0;i<splitString.length;i++)
	{
		if(document.getElementById(splitString[i])){
			document.getElementById(splitString[i]).disabled = howto;
		}
	}
}
// elementÀÇ readOnly Á¦¾î
function setReadOnly(str, how) // strÀº ,·Î ±¸ºÐµÈ ÇÊµå ¾ÆÀÌµð, how´Â trueÀÎÁö falseÀÎÁö(1,0)
{
	howto = (how==1)?true:false;
	splitString = str.split(",");
	for (i=0;i<splitString.length;i++)
	{
		if(document.getElementById(splitString[i])){
			document.getElementById(splitString[i]).readOnly = howto;
		}
	}
}
// elementÀÇ style.display Á¦¾î
function setDisplay(str, how) // strÀº ,·Î ±¸ºÐµÈ ÇÊµå ¾ÆÀÌµð, how´Â blockÀÎÁö noneÀÎÁö(1,0)
{
	howto = (how==1)?"block":"none";
	splitString = str.split(",");
	
	for (i=0;i<splitString.length;i++)
	{
		//alert(splitString[i]);
		//alert(howto);
		if(document.getElementById(splitString[i])){
			document.getElementById(splitString[i]).style.display = howto;
		}
	}
}
// elementÀÇ value ¼³Á¤
function setValue(str,how) // strÀº ,·Î ±¸ºÐµÈ ÇÊµå ¾ÆÀÌµð, how´Â °ª
{
	splitString = str.split(",");
	for (i=0;i<splitString.length;i++)
	{
		if(document.getElementById(splitString[i])){
			document.getElementById(splitString[i]).value = how;
		}
	}
}
// elementÀÇ value °®°í¿È
function getValue(str)
{
	return document.getElementById(str).value;
}
// °ü½É»óÇ°(ÂòÇÏ±â) µî·Ï
function zzimItem(id_code)
{
	process.location.replace('/mypage/mypage_wishlist_process_redirect.php?id_code='+id_code);
}
function zzimItem_1(id_code)
{
	process.location.replace('/mypage/mypage_wishlist_process_redirect.php?cart=1&id_code='+id_code);
}

/*
	³Ö´Â ¹æ¹ý
	<input onKeyUp="return autoTab(this, 6, event);" size="7" maxlength="6"> -
	<input onKeyUp="return autoTab(this, 7, event);" size="8" maxlength="7">
*/
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}

	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length) {
			if(arr[index] == ele)
				found = true;
			else
				index++;
		}
		return found;
	}

	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1) {
			if (input.form[i] == input)
				index = i;
			else
				i++;
		}
		return index;
	}
	return true;
}
/* ÇÔ¼ö ³¡ */

// ¹è°æ»ö ¹Ù²Ù±â obj:srcElement, color:ÄÃ·¯ÄÚµå È¤Àº ÄÃ·¯¸í, xcursor:0 or 1 : ¸¶¿ì½ºÄ¿¼­¸¦ ¼Õ¸ð¾çÀ¸·ç ÇÒÁö
function m_act(obj,color,xcursor)
{
	obj.style.backgroundColor = color;
	obj.style.cursor=(xcursor)?"pointer":"default";
}

//  ½ºÇÁ·¹µå...
function spread(what, how)
{
	obj = document.getElementById(what); //eval("document.all."+what);
	if (!isNaN(how)){
		obj.style.display = (how)?"block":"none";
	} else if (how=="toggle")
	{
		obj.style.display = (obj.style.display=="none")?"block":"none";
	}
}

// »óÇ°Æò º°±×¸®±â
function item_ps_score(image_path, num) // »óÇ°Æò¿¡ µé¾î°¥ º°À» ±×¸°´Ù.
{
	var starcode = "";
	for	(i=0;i<num;i++)
	{
		starcode += "<img src='"+image_path+"' align='absmiddle'>";
	}
	document.writeln(starcode);
}

// »óÇ°Æò ¾²±â : how=0 ºñÈ¸¿ø how=1 È¸¿ø
function post_item_ps(how)
{
	if (how==0)
	{if(confirm("·Î±×ÀÎÇÏ¼Å¾ß ÀÛ¼ºÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù. ·Î±×ÀÎÇÏ½Ã°Ú½À´Ï±î?")){intoLogin();}}
	else
	{window.open("item_post_ps.php","postps","width=600,height=400");}
}
   