var url, NeverdieEventUrl, NeverdieItemUrl, NeverdiePromotionUrl;
if (location.hostname.indexOf("dev") >= 0 ){
	url = 'http://dev.gmarket.co.kr/';
	NeverdieEventUrl = 'http://eventdev.gmarket.co.kr/';
	NeverdieItemUrl = 'http://itemdev.gmarket.co.kr/';
	NeverdiePromotionUrl = 'http://promotiondev.gmarket.co.kr/';
}
else {
	url = 'http://www.gmarket.co.kr/';
	NeverdieEventUrl = 'http://event.gmarket.co.kr/';
	NeverdieItemUrl = 'http://item.gmarket.co.kr/';
	NeverdiePromotionUrl = 'http://promotion.gmarket.co.kr/';
}

// 2008-12-03 ³» ÄíÆùÇÔ °¡·Î ¼¼·Î Å©±â
var fixed_coupon_box_width	= 574
var fixed_coupon_box_height	= 570
// 2007-07-27 ÀÌ¼º±Ù (ÆäÀÌÁö ·Îµù Áß Æ¯Á¤ ÀÌ¹ÌÁö ¹öÆ° ÀÌº¥Æ® ¹«·ÂÈ­)
function cancelLink() {

    try {
	if (document.readyState != "complete") {
		if (window.event.srcElement.tagName == "IMG")
		{
//			alert(event.srcElement.src);
//			window.status = event.srcElement.src;

			// ÀÌ¹ÌÁö ID·Î ¸·±â
			var key = event.srcElement.id;
			if (key == "animatedImgStatChgBtn"
				|| key == "onoff_btn"
				|| key == "topanimatedImgStatChgBtn"
				|| key == "imgDownBtn"
				|| key == "imgUpBtn"
				|| key == "down_banner_btn"
				|| key == "up_banner_btn"
			)
			{
				window.event.returnValue = false;
			}

			// ÀÌ¹ÌÁö °æ·Î·Î ¸·±â
			var key = event.srcElement.src;
			if (key == "http://image.gmarket.co.kr/challenge/neo_image/newmain5/img_ms.gif"
				|| key == "http://image.gmarket.co.kr/challenge/neo_image/newmain5/button_down1.gif"
				|| key == "http://image.gmarket.co.kr/challenge/neo_image/newmain5/button_up1.gif"
			)
			{
				window.event.returnValue = false;
			}
		}
	}
	}
	catch (e)
	{
	    window.status = "ÇöÀç ºê¶ó¿ìÀú¿¡¼­ ÇØ´ç ±â´ÉÀ» Áö¿øÇÏÁö ¾Ê½À´Ï´Ù.";
	}
}

document.onclick = cancelLink;

function isSpace(inChar)
{
	return (inChar == ' ' || inChar == '\t' || inChar == '\n');
}

// trim ÇÔ¼ö
function trim(tmpStr)
{
	var atChar;
	if (tmpStr.length > 0)
	atChar = tmpStr.charAt(0);
	while (isSpace(atChar))
	{
		tmpStr = tmpStr.substring(1, tmpStr.length);
		atChar = tmpStr.charAt(0);
	}
	if (tmpStr.length > 0)
		atChar = tmpStr.charAt(tmpStr.length-1);
	while (isSpace(atChar))
	{
		tmpStr = tmpStr.substring(0,( tmpStr.length-1));
		atChar = tmpStr.charAt(tmpStr.length-1);
	}
	return tmpStr;
}

function MM_findObj(n, d)
{ //v3.0
	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);
		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 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 cardInfo(master_card)
{
	window.open('/trading/write_card.asp?master_card='+master_card, '', 'width=500, height=220, nostatus, notoolbar');
	return false;
}

function show(name)
{
	var id = document.all[name]
	id.style.display = "none" == id.style.display ? "" : "none";
}

function selectwidget(name)
{
	var id = document.all[name]
	id.style.display = "";
}

function hiden(name)
{
	var id = document.all[name]
	id.style.display = "none"
}

function goGDMC(s)
{
	if (s.options[s.selectedIndex].value!='')
	{
		document.location = (url + 'trading/large_category'+s.options[s.selectedIndex].value.charAt(0)+'.asp?gdlc_cd='+s.options[s.selectedIndex].value.substring(3));
	}
}

function edealer_10_Q()
{
	window.open(url+'etc_page/e-dealer.htm','','width=530,height=700,scrollbars=yes,resizable=yes')
}

function goGDSC(s)
{
	if (s.options[s.selectedIndex].value!='')
	{
		document.location = url + 'trading/GDSC_TradeInfo.asp?strgdsc_cd='+s.options[s.selectedIndex].value;
	}
}

function hogaPopup(gd_no)
{
	window.open(url + 'trading/hoga.asp?goodscode='+gd_no, '', 'width=500, height=328')
}

function del_inter_gd(gd_no,cust_no)
{
	window.open("delete_ptfoliot.asp?goodscode="+gd_no+"&cust_no="+cust_no+"", "", "width=2,height=2,left=10000")
}

function helpPop(URL)
{
	var i,child
	child = window.open(url+'help/helpmain.asp?page='+URL, 'HELP', 'notoolbars, width=800, height=570');
//	for (i=0; i< 1000000; i++){i=i-1;i=i+1;}
	//alert(URL);
	//child.right.document.location = URL;
}

function compPrice(gd_no)
{
	child = window.open(url + 'compPrice.asp?goodscode='+gd_no, 'compPrice', 'width=500, height=300, scrollbars=yes, resizable=yes')
}

//Á¾¼ö°¡ Ãß°¡ÇÑ ÇÔ¼ö. ÀÚµ¿À¸·Î ´ÙÀ½ ÅØ½ºÆ® ¹Ú½º·Î Æ÷Ä¿½º¸¦ ÀÌµ¿½ÃÅ²´Ù.
function js_next_focus(obj,sLength,sNext)
{
	if (obj.value.length == sLength)
	{
		document.getElementsByName(sNext)[0].focus()
	}
}

//Á¾¼ö°¡ Ãß°¡ÇÑ ÇÔ¼ö. ÀÌ¹ÌÁö¸¦ ÆÈµüÆÈµü ¶Ù°Ô ¸¸µç´Ù.
function js_move_img(obj,flag)
{
	if (flag)
	{
		//obj.style.posBottom=0
		//obj.height += 2
		return false
	}
	else
	{
		//obj.style.posBottom=0
		//obj.height -= 2
		return true
	}
}

function js_money(x)
{
	var i,ii,y
	y=""
	x=String(x)

	for (i=x.length-1;i >= 0 ;i--)
	{
		ii=x.length-1-i
		flag=(ii+1) % 3

		if ((flag == 0) && ( ii != x.length-1 ))
			y=","+x.charAt(i)+y
		else
			y=x.charAt(i)+y
	}

	return y
}

function choose_one(sSel,sValue)
{
	for(i=0;i < sSel.length;i++)
	{
		if (sSel.options[i].value == sValue)
		{
			sSel.selectedIndex=i
			return true
		}
		else
		{
			sSel.selectedIndex=0
		}
	}
}

function isempty(obj,isNumber,sMsg,obj_type)
{
	//obj ÀÇ À¯Çü¿¡ µû¶ó ´Ù¸£´Ù. ¸¸¾à ¶óµð¿À ¹öÆ°ÀÌ¸é ÄÃ·º¼ÇÀÌ ³Ñ¾î¿Í¾ß ÇÑ´Ù.
	if (typeof(obj_type) == "undefined")
	{
		obj_type = "TEXT"
	}

	if (obj_type.toUpperCase() == "RADIO")
	{
		var isChecked = false;

		for (i = 0; i < obj.length; i++)
		{
			if (obj[i].checked)
			{
				isChecked = true;
				return false;
			}
		}

		if (!isChecked)
		{
			window.alert(sMsg+" ¼±ÅÃÇÏ¼Å¾ß ÇÕ´Ï´Ù.")
			obj[0].focus();
			return true;
		}
	}
	else
	{
		//°ªÀÌ ºñ¾îÀÖ´ÂÁö Ã¼Å©
		if (obj.value == "")
		{
			window.alert(sMsg+" ÀÔ·ÂÇÏ¼¼¿ä.")
			obj.focus()
			obj.select()
			return true
		}
		//¼ýÀÚÀÎÁö Ã¼Å©
		if (isNumber)
		{
			if (isNaN(Number(obj.value)))
			{
				window.alert("¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.")
				obj.focus()
				obj.select()
				return true
			}
		}
		else
		{
			return false
		}
	}
}

//¶óµð¿À ¹öÆ° ¼±ÅÃÇÏÀÚ.
function set_radio_btn(which, value)
{
	var target = document.getElementsByName(which)

	if (target == null)
		return
	else
	{
		for (i=0; i< target.length; i++)
		{
			if (target[i].value.toUpperCase() == value.toUpperCase())
			{
				target[i].checked = true;
			}
		}
	}
}
/*
function isempty(obj,isNumber,sMsg)
{
	//°ªÀÌ ºñ¾îÀÖ´ÂÁö Ã¼Å©
	if (obj.value == "")
	{
		window.alert(sMsg+" ÀÔ·ÂÇÏ¼¼¿ä.")
		obj.focus()
		obj.select()
		return true
	}

	//¼ýÀÚÀÎÁö Ã¼Å©
	if (isNumber)
	{
		if (isNaN(Number(obj.value)))
		{
			window.alert("¼ýÀÚ¸¸ °¡´ÉÇÕ´Ï´Ù.")
			obj.focus()
			obj.select()
			return true
		}
	}
	else
	{
		return false
	}
}
*/
function make_number(sInput)
{
	//¼ýÀÚ·Î ¸¸µé¾îº¸ÀÚ.
	var i=0

	for (i=0;isNaN(sInput) && (i <= 10);i++)
	{
		sInput=sInput.replace(",","")
	}

	if (isNaN(sInput))
	{
		window.alert("ÄÞ¸¶(,) ¸¦ Á¦¿ÜÇÑ ¹®ÀÚ¸¦ ³ÖÁö ¸¶¼¼¿ä.")
		return false
	}
	else
	{
		return Number(sInput)
	}
}

// Create a cookie with the specified name and value.
// The cookie expires at the end of the 20th century.
function SetCookie(sName, sValue)
{
	document.cookie = sName + "=" + escape(sValue) + ";"
}

function SetCookie_PathRoot(sName, sValue)
{
	document.cookie = sName + "=" + escape(sValue) + "; path=/;"
}

// Retrieve the value of the cookie with the specified name.
function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");

	for (var i=0; i < aCookie.length; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
		return unescape(aCrumb[1]);
	}

	// a cookie with the requested name does not exist
	return null;
}

//ÀÌ¸ÞÀÏ Ã¼Å©
function isValidEmail(s) {
	if (s.indexOf(" ") >=0)
	{
		window.alert("°ø¹éÀ» Æ÷ÇÔÇÒ ¼ö´Â ¾ø½À´Ï´Ù.")
		return false;
	}

	var re = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	return (re.test(s));
}

//¹«ÀÌÀÚ ÇÒºÎÁ¤º¸ iframeÀ» ·¹ÀÌ¾îÀÇ ¹è°æÀ¸·Î ¼ÂÆÃÇÏ¿© select ¹Ú½º°¡ ¾Èº¸ÀÌµµ·Ï ÇÑ´Ù.
function showFreeInterestCardIfrmLayer( no ){
    var DivRef = document.getElementById('FreeInterestCardLayer_' + no );
    var IfrRef = document.getElementById('FreeInterestCardIfrmLayer_' + no );

    if ( IfrRef != null ) {
	    IfrRef.style.width = DivRef.offsetWidth-6;
		IfrRef.style.height = DivRef.offsetHeight;
		IfrRef.style.top = DivRef.style.top;
		IfrRef.style.left = DivRef.style.left;
		IfrRef.style.zIndex = DivRef.style.zIndex - 1;
		IfrRef.style.display = "block";
	}
}

//¹«ÀÌÀÚ ÇÒºÎÁ¤º¸ ·¹ÀÌ¾îÀÇ ¹è°æÀÌ µÇ´Â iframeÀ» °¨Ãá´Ù.
function hiddenFreeInterestCardIfrmLayer(  no ){
    var IfrRef = document.getElementById('FreeInterestCardIfrmLayer_' + no );
    if ( IfrRef != null )
	    IfrRef.style.display = "none";
}

//¹«ÀÌÀÚ ÇÒºÎÁ¤º¸ ·¹ÀÌ¾î¸¦ º¸¿©ÁØ´Ù.
function showFreeInterestCardLayer(no)
{
	eval("FreeInterestCardLayer_" + no + ".style.display = 'inline';");
	showFreeInterestCardIfrmLayer( no );
}

//¹«ÀÌÀÚ ÇÒºÎÁ¤º¸ ·¹ÀÌ¾î¸¦ °¨Ãá´Ù.
function hiddenFreeInterestCardLayer(no)
{
    hiddenFreeInterestCardIfrmLayer( no  );
	eval("FreeInterestCardLayer_" + no + ".style.display= 'none';");
}

// '<', '>' °¡ ÀÖ´ÂÁö È®ÀÎÇÑ´Ù.
function hasTagSymbol(str) {
	var re = /<|>/g;
	return (re.test(str));
}

// »ç¿ëÇÒ ¼ö ¾ø´Â Å°¿öµå Ã¼Å© - ¹Ì´Ï¼¥¸í
function hasInvalidShopName(str) {
	var re = /(G¸¶ÄÏ|Áö¸¶ÄÏ|Áã¸¶ÄÏ|G-mall|G_mall|Áö¸ô|ÆÄ¿öµô·¯|¿ì¼öµô·¯)/gi;
	return (re.test(str));
}

// stringÀÇ byte ¼ö¸¦ ±¸ÇÑ´Ù.
function getStringByteLength(pStr)
{
    var c;
    var nLength = 0;
    var sStr = new String(pStr);

    for(i=0; i < sStr.length; i++)
    {
        c = sStr.charAt(i);
        if(escape(c).length > 4 )   // ÇÑ±Û
            nLength += 2;
        else
            nLength++;
    }
    return nLength;
}

// stringÀ» byte ¸¸Å­ ÀÚ¸¥´Ù.
function cutStringByteLength(pStr, iLength)
{
	if (iLength == 0) return ("");

	var c;
    var nLength = 0;
    var sStr = new String(pStr);
	var sResultStr = "";

    for(i=0; i < sStr.length; i++)
    {
        c = sStr.charAt(i);
        if(escape(c).length > 4 )   // ÇÑ±Û
		{
			if (nLength + 2 > iLength)
				return sResultStr;
			else
				nLength += 2;
		}
        else
		{
			if (nLength + 1 > iLength)
				return sResultStr;
			else
	            nLength++;
		}
		sResultStr += c;
    }
    return sResultStr;
}

// ¹®ÀÚ¿­ Ã¼Å© ÇÔ¼ö
// ÇÑ±Û, ¾ËÆÄºª, ¼ýÀÚ, °ø¹é, Çã¿ëÇÏ·ÁÇÏ´Â Æ¯¼ö ¹®ÀÚÀÇ Á¶ÇÕÀ¸·Î »ç¿ë °¡´É.
function hasInvalidSymbol(text, symbol, allowKorean, allowAlpha, allowNum, allowSpace) {
	if (text == "")
		return false;

	var expression = "/[^";
	expression += (allowKorean) ? "¤¡-ÆR" : "";
	expression += (allowAlpha) ? "a-zA-Z" : "";
	expression += (allowNum) ? "0-9" : "";
	expression += (allowSpace) ? " " : "";
	if (symbol != "") {
		symbol = symbol.replace(/(.)/g, "\\$1");
		expression += symbol;
	}
	expression += "]/";

	var re = eval(expression);
	return (re.test(text));
}

function goSimplePage(sGoodsCode)
{
    var clientHeight;
    var obj;

    if(navigator.appVersion.indexOf("Windows NT 5.1")!=-1) {
        clientHeight = 395;
    }else {
        clientHeight = 395;
    }

	GmktPopLayerAdd(NeverdieItemUrl + 'detailminiview/ItemMini.asp?goodscode=' + sGoodsCode+'#'+document.domain, 919, 603 )
}

function goEtcSimplePage(sGoodsCode, sSid, sInterGrpNo)
{
// ±âÈ¹Àü°ú °ü½É»óÇ°¿¡¼­ ³Ñ°ÜÁÙ¶§ »ç¿ëÇÏ´Â ÇÔ¼ö´Ù
    var clientHeight;
    var obj;

    if(navigator.appVersion.indexOf("Windows NT 5.1")!=-1) {
        clientHeight = 395;
    }else {
        clientHeight = 395;
    }

	obj=window.open(url+"challenge/neo_simple_goods/simple_goods_frame.asp?goodscode=" + sGoodsCode + "&sid=" + sSid + "&interest_group_no=" + sInterGrpNo, "SimpleGoodsPage", "width=755, height="+clientHeight+", scrollbars=no, toolbar=no , status=no");
	obj.focus();
}

//¹®ÀÚ¼­ºñ½º ÆË¾÷
function goGmsServicePop(){
	var w = 800;
	var h = 600;
	var gms_main_pop = window.open(url + 'challenge/neo_gms/gms_main.asp', 'gms_main', 'top='+(screen.height-h)/3+',left='+(screen.width-w)/2+',toolbar=no, history=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width='+w+', height='+h);
	gms_main_pop.focus();
}

function goDayCalendarPop() {
	var w = 810;
	var h = 550;
	var calendar_pop = window.open(NeverdiePromotionUrl + "daycalendar/DayCalendar.asp", "calendar_pop", "top="+(screen.height-h)/3+", left="+(screen.width-w)/2+", toolbar=no, history=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+w+", height="+h);
	calendar_pop.focus();
}

// ÆäÀÌÁö ·Îµù Ã¼Å© ½ÃÀÛ 20080222 extream
var loading_time = 0 ;
var loading_time_check_yn = "N"
var start_time = new Date();
start_time = start_time.getTime();

function  get_loading_time()
{
	loading_time = loaging_time_getCookie('gmkt_loading_time')
	loading_time_check_yn = loaging_time_getCookie('gmktloadingtimecheck')

	if 	(loading_time_check_yn == "N")
	{
		var end_time = new Date();
		end_time = end_time.getTime();
		var secs = (end_time - start_time) /1000;

		loaging_time_setCookie('gmkt_loading_time',secs,0)
	}
}

function loaging_time_setCookie( name, value, expiredays )
{
	document.cookie = name + "=" + escape( value ) + "; path=/; Domain=gmarket.co.kr;"
}

function loaging_time_getCookie(name) {
    var Found = false
    var start, end
    var i = 0

    while(i <= document.cookie.length) {
	    start = i
		end = start + name.length

	    if(document.cookie.substring(start, end) == name) {
		    Found = true
			break
	    }
		i++
    }

    if(Found == true) {
	    start = end + 1
		end = document.cookie.indexOf(";", start)
	    if(end < start)
		end = document.cookie.length
	    return document.cookie.substring(start, end)
    }
    return ""
}
// ÆäÀÌÁö ·Îµù Ã¼Å© ³¡

// string prototype definition, common functions
String.prototype.byte = function(){

	var cnt = 0;
	var chr = "";

	for( var i = 0; i < this.length; i++)
	{
		chr = this.charAt(i);
		if( escape( chr ).length > 4 ){
			cnt += 2;
		}else{
			cnt++;
		}
	}

	return cnt;
}

String.prototype.ltrim = function() {
	var re = /\s*((\S+\s*)*)/;
	return this.replace(re, "$1");
}

String.prototype.rtrim = function() {
	var re = /((\s*\S+)*)\s*/;
	return this.replace(re, "$1");
}

String.prototype.trim = function() {
	return this.ltrim().rtrim();
}


function getObjInnerText(obj) {
    return (obj.innerText) ? obj.innerText : (obj.textContent) ? obj.textContent : "";
}


function setObjInnerText(obj, str) {
    if (obj.innerText) {
        obj.innerText = str;
        return 0;
    }
    else {
        if (obj.textContent) {
            obj.textContent = str;
            return 0;
        }
        else {
            return -1;
        }
    }
}

function getUserAgentName()
{
	var agent = navigator.userAgent;
	var agentName = "";

	if( /Firefox[\/\s](\d+\.\d+)/.test(agent) ){//test for Firefox
		agentName = "FF";
	}else if( /MSIE (\d+\.\d+);/.test(agent) ){
		agentName = "IE";
	}else if( /Opera[\/\s](\d+\.\d+)/.test(agent) ){
		agentName = "OP";
	}else{
		agentName = "NA";
	}

	return agentName;
}


function CommonApplyEvent2(Str, encStr, reloadYn){
	SetCookie_PathRoot("Cif", Str);
	SetCookie_PathRoot("CSif", encStr);

	if (typeof(reloadYn) == "undefined")
	{
		reloadYn = "N"
	}

	window.open("/challenge/neo_event_platform/event_common_apply.asp?sif="+Str+"&reload="+reloadYn, "eventpop", "width=350, height=185, left=500, top=400, scrollbars=no,status=no,toolbar=no");
	return;
}

function CommonApplyEventPlatform(Str, encStr, reloadYn, password, groupYn) {
	document.cookie = "ECif" + "=" + escape(encStr) + "; path=/;domain=gmarket.co.kr";

	if (typeof (reloadYn) == "undefined") {
		reloadYn = "N";
	}

	if (typeof (password) == "undefined") {
		password = "";
	}

	if (typeof (groupYn) == "undefined") {
		groupYn = "N";
	}

	var openerURL = document.URL;

	window.open(NeverdieEventUrl + "eventplatform/EventPlatformApply.asp?epif="+Str+"&reload="+reloadYn+"&groupYn="+groupYn+"&password="+password + "&openerURL=" + openerURL , "eventpop", "width=350, height=185, left=500, top=400, scrollbars=no,status=no,toolbar=no");
	return;
}

function goBasketCommon(pObjName) {

	var listform;

	for(i=0; i<document.forms.length; i++){

		if (document.forms[i].name == pObjName)
		{
			listform = document.forms[i];
		}
	}

	if (listform.goodscode == null) {
		alert ("Àå¹Ù±¸´Ï¿¡ ´ãÀ» »óÇ°ÀÌ ¾ø½À´Ï´Ù.\n\n¿øÇÏ´Â »óÇ°À» °Ë»öÇÏ½Å ÈÄ, Àå¹Ù±¸´Ï¿¡ ´ãÀ» »óÇ°À» ¼±ÅÃÇÏ¼¼¿ä.");
		return;
	}

	var iCheckedCnt = listform.goodscode.length;
	var bAlert = false;

	var bChecked = false;
	var bChkCnt = 0;
	var aChkCnt = 0;
	var bChkArr = new Array();
	var alertMsg = "";

	if (iCheckedCnt == null) { // Search Result Only 1
		if (!listform.goodscode.checked) {
			alert ("Àå¹Ù±¸´Ï¿¡ ´ãÀ» »óÇ°À» ¼±ÅÃÇÏ¼¼¿ä.");
			return;
		}
		if (listform.check_value.value != "") {
			bAlert = true;
			bChkCnt = -1;
		}
	}else{ // Sesarch Result More 2
		for (i = 0; i < iCheckedCnt; i++) {
			if (listform.goodscode[i].checked) {
				bChecked = true;

				if (listform.check_value[i].value != "") {
					alertMsg = alertMsg + "\n - " + listform.gd_nm[i].value;
					bAlert = true;
					bChkCnt++;
					bChkArr.push(i);
				}
				aChkCnt++;
			}
		}
		if (!bChecked) {
			alert ("Àå¹Ù±¸´Ï¿¡ ´ãÀ» »óÇ°À» ¼±ÅÃÇÏ¼¼¿ä.");
			return;
		}
	}

	if (bAlert) {
		if (bChkCnt == -1){  // Search Result Only 1
			var alertMsgDefault = "¼±ÅÃÇÏ½Å »óÇ°Àº [¼±ÅÃÁ¤º¸(¿É¼Ç¼±ÅÃ)] ¶Ç´Â [°æ¸ÅÁ¤º¸],[¿©Çà/¿¹¾àÁ¤º¸],[C2 »óÇ°Á¤º¸]°¡\nÇÊ¿äÇÑ »óÇ°ÀÌ Æ÷ÇÔµÇ¾îÀÖ½À´Ï´Ù. [Àå¹Ù±¸´Ï ´ã±â]´Â »óÇ° »ó¼¼ ÆäÀÌÁö¿¡¼­ °¡´ÉÇÕ´Ï´Ù.\n";
			alert (alertMsgDefault);
			listform.goodscode.checked = false;
		}else if (aChkCnt == 1 && bChkCnt == 1){
			var alertMsgDefault = "¼±ÅÃÇÏ½Å »óÇ°Àº [¼±ÅÃÁ¤º¸(¿É¼Ç¼±ÅÃ)] ¶Ç´Â [°æ¸ÅÁ¤º¸],[¿©Çà/¿¹¾àÁ¤º¸],[C2 »óÇ°Á¤º¸]°¡\nÇÊ¿äÇÑ »óÇ°ÀÌ Æ÷ÇÔµÇ¾îÀÖ½À´Ï´Ù. [Àå¹Ù±¸´Ï ´ã±â]´Â »óÇ° »ó¼¼ ÆäÀÌÁö¿¡¼­ °¡´ÉÇÕ´Ï´Ù.\n";
			alert (alertMsgDefault);
			listform.goodscode[bChkArr[0]].checked = false;
		}else{
			var alertMsgDefault = "¼±ÅÃÇÏ½Å »óÇ° Áß [¼±ÅÃÁ¤º¸(¿É¼Ç¼±ÅÃ)] ¶Ç´Â [°æ¸ÅÁ¤º¸],[¿©Çà/¿¹¾àÁ¤º¸],[C2 »óÇ°Á¤º¸]°¡\nÇÊ¿äÇÑ »óÇ°ÀÌ Æ÷ÇÔµÇ¾îÀÖ½À´Ï´Ù. [Àå¹Ù±¸´Ï ´ã±â]´Â »óÇ° »ó¼¼ ÆäÀÌÁö¿¡¼­ °¡´ÉÇÕ´Ï´Ù.\n\n* Ãß°¡Á¤º¸ ÇÊ¿äÇÑ »óÇ° List\n";
			alert (alertMsgDefault + alertMsg);
			for (var icnt = 0; icnt < bChkArr.length; icnt ++) {
				listform.goodscode[bChkArr[icnt]].checked = false;
			}
		}
		return;
	}

	var top, left
	try{
		top = screen.availHeight/2 - 180/2;
		left = screen.availWidth/2 - 458/2;
	}catch (e){
		top = 100;
		left = 100;
	}

	var goBasketWin = window.open(url+"challenge/neo_include/dummy.asp", "goBasketWin", "width=458, height=180, scrollbars=yes, status=no, resizable=no left="+ left +", top="+ top +"");
	listform.target = "goBasketWin";
	listform.action = url+"challenge/neo_order/gmktGoBasket.asp";
	listform.submit();
	goBasketWin.focus();
}


function getKeyValue()
{
	var regexResult = /key=(\d+)+/.exec(window.location.hash);
	if (regexResult && regexResult.length > 1)
	{
		return parseInt(regexResult[1]);
	}
	return 0;
}

function checkHistoryBack( limitTime )
{
	var keyValue = getKeyValue();
	var currentDate = new Date();
	if (keyValue == 0)
	{
		window.location.hash = "key=" + currentDate.valueOf();
	}
	else
	{
		var delta = currentDate.valueOf() - keyValue
		if (delta > limitTime)
		{
            location.replace(url+"error_log/expired.asp");
		}
	}
}

function checkHistoryBackAlertAndGo( limitTime, pAlertMsg, pURL)
{
	var keyValue = getKeyValue();
	var currentDate = new Date();
	if (keyValue == 0)
	{
		window.location.hash = "key=" + currentDate.valueOf();
	}
	else
	{
		var delta = currentDate.valueOf() - keyValue
		if (delta > limitTime)
		{
			alert(pAlertMsg);
			location.replace(pURL);
		}
	}
}

function checkHistoryBackNoAlertAndGo( limitTime, pURL)
{
	var keyValue = getKeyValue();
	var currentDate = new Date();
	if (keyValue == 0)
	{
		window.location.hash = "key=" + currentDate.valueOf();
	}
	else
	{
		var delta = currentDate.valueOf() - keyValue
		if (delta > limitTime)
		{
			location.replace(pURL);
		}
	}
}

function checkAdLink(sSuccBidNo,sLinkUrl,sAdTarget,sAdType,sDivForm)
{
	if (document.getElementById(sDivForm))
	{
		if (sSuccBidNo > 100000)
		{
			document.getElementById(sDivForm).src = "http://bidadlog.gmarket.co.kr/adcheck.html?succ_bid_no="+sSuccBidNo+"&ad_type="+sAdType ;
		}

	}

	if (sAdType == 2)
	{
		if (sAdTarget == "_blank")
		{
			window.open(sLinkUrl);
		}
		else
		{
			location.href = 	sLinkUrl;
		}
	}
}
function GmktIframeReload( sIdStr )
{
	var IframeLayer     = document.getElementById(sIdStr);
	if ( IframeLayer ) IframeLayer.contentWindow.location.reload();
}
var GMKTpopLayerIndex = 0;
var GMKTpopLayerParentReload = "N";
function GmktTopLeft(){
    var T, L;
	if (window.pageYOffset){T = window.pageYOffset }
	else if(document.documentElement && document.documentElement.scrollTop){T = document.documentElement.scrollTop; }
	else if(document.body){ T = document.body.scrollTop; }
	if(window.pageXOffset){ L=window.pageXOffset }
	else if(document.documentElement && document.documentElement.scrollLeft){L=document.documentElement.scrollLeft; }
	else if(document.body){ L=document.body.scrollLeft; }
	arrTopLeft = new Array( T, L );
	return arrTopLeft;
}
function GmktPageSize() {
	var W1,W2,H1,H2;
	var pageWidth,pageHeight;
	if(window.innerHeight&&window.scrollMaxY){
		W2=document.body.scrollWidth;
		H1=window.innerHeight+window.scrollMaxY
	}else{
		if(document.body.scrollHeight>document.body.offsetHeight){
			H1=document.body.scrollHeight
		}else{
			H1=document.body.offsetHeight
		}
		if(document.body.scrollWidth>document.body.offsetWidth){
			W2=document.body.scrollWidth;
		}else{
			W2=document.body.offsetWidth;
		}
	}
	if(self.innerHeight){
		W1=self.innerWidth;
		H2=self.innerHeight
	}else{
		if(document.documentElement&&document.documentElement.clientHeight){
			W1=document.documentElement.clientWidth;
			H2=document.documentElement.clientHeight
		}else{
			if(document.body){
				W1=document.body.clientWidth;
				H2=document.body.clientHeight
			}
		}
	}
	if(H1<H2){
		pageHeight=H2
	}else{
		pageHeight=H1
	}
	if(W2<W1){
		pageWidth=W1
	}else{
		pageWidth=W2
	}
	arrPageSize=new Array(pageWidth,pageHeight,W1, H2);
	return arrPageSize;
}
function GmktPopLayerSetParentReload( str ) {
	GMKTpopLayerParentReload = str ;
}
function GmktPopLayerInit(callback, sUrl, sWidth, sHeight, sClickYn ) {
    var fileref= document.createElement('link');
		var tmpUrl = location.href ;
		var tmpCss;
		if (tmpUrl.indexOf("dev") < 0 )
		{
			if ( tmpUrl.indexOf("https://") < 0 )
				tmpCss = "http://script.gmarket.co.kr/css/common/dimmed.css";
			else
				tmpCss = "https://script.gmarket.co.kr/css/common/dimmed.css";
		} else {
			if ( tmpUrl.indexOf("https://") < 0 )
				tmpCss = "http://scriptdev.gmarket.co.kr/css/common/dimmed.css";
			else
				tmpCss = "https://scriptdev.gmarket.co.kr/css/common/dimmed.css";
		}
		// add poplayer css
		fileref.setAttribute("rel", "stylesheet")
		fileref.setAttribute("type", "text/css")
		fileref.setAttribute("href", tmpCss );
	if ( navigator.appVersion.indexOf("MSIE") > -1 )
	{
		var loaded = false;
		fileref.onreadystatechange= function () {
			if (this.readyState == 'loaded' || this.readyState == 'complete') {
				if (loaded) {
					return;
				}
				loaded = true;
				callback(sUrl, sWidth, sHeight, sClickYn );
			}
		}
	}
	else {
		callback(sUrl, sWidth, sHeight, sClickYn );
	}
		if (typeof fileref!="undefined")
		  document.getElementsByTagName("head")[0].appendChild(fileref);
}
function GmktPopLayerAddOrigin(sUrl, sWidth, sHeight, sClickYn )
{
	var popLayer     = document.getElementById("GmktPopLayer");
	if ( !popLayer )
	{
		// create poplayer
		var newPopLayer = document.createElement("div");
		newPopLayer.setAttribute('id','GmktPopLayer');
		newPopLayer.className ="poplayer";
		document.body.appendChild(newPopLayer);
		popLayer = newPopLayer;
	}
	var arrPageSize, arrTopLeft;
	arrPageSize = GmktPageSize();
	arrTopLeft = GmktTopLeft();

	popLayer.style.height = arrPageSize[1] + "px";
	popLayer.style.width = arrPageSize[0]+ "px";

	GMKTpopLayerIndex++;
	var element      = document.createElement("div");
	element.setAttribute('id','popLayer' + GMKTpopLayerIndex );

	element.className ="poplayer";
	element.style.height = arrPageSize[1] + "px";
	element.style.width = arrPageSize[0]+ "px";
	element.style.zIndex = 99998 +  GMKTpopLayerIndex ;

	var dimmed =  document.createElement("div");
	dimmed.setAttribute('id','popLayerDimmed' + GMKTpopLayerIndex );
	dimmed.className ="dimmed";
	if ( sClickYn == "Y" ) dimmed.onclick = GmktPopLayerDelete;
	else dimmed.onclick = GmktPopLayerNull;

	dimmed.style.width = arrPageSize[0]+ "px";
	if ( navigator.appVersion.indexOf("MSIE") > -1 &&  arrPageSize[1] > 4096 )
	{
		var dTop = document.body.scrollTop || document.documentElement.scrollTop;
		dimmed.style.height = 4096 + "px";
		if ( ( dTop + 4096 ) <  arrPageSize[1] ) dimmed.style.top = dTop - 1500;
		else dimmed.style.top = ( arrPageSize[1] - 4096 ) + "px";
	} else
		dimmed.style.height = arrPageSize[1] + "px";

	if ( (/MSIE (6)/).test(navigator.userAgent) )
	{
		var dIframe = document.createElement('iframe');
		dIframe.setAttribute('id', 'popLayerDimmedIframe' + GMKTpopLayerIndex  );
		dIframe.className = "blocker";
		if (sClickYn == "Y" )
			dIframe.src = "/challenge/neo_include/GmktPopLayerEvent.asp";
		else
			dIframe.src = 'about:blank';
		dimmed.appendChild(dIframe);

	}
	element.appendChild(dimmed);

	var contents = document.createElement("div");
	contents.setAttribute('id','popLayerContents' + GMKTpopLayerIndex );
	contents.className = "frame_setting";
	if ( sClickYn == "Y" ) contents.onclick = GmktPopLayerDelete;
	else contents.onclick = GmktPopLayerNull;
	var iTempTop = (arrPageSize[3] / 2) -  ( sHeight / 2) + ( arrTopLeft[0] )
	iTempTop = iTempTop < 0 ? 0 : iTempTop;
	contents.style.top = iTempTop  + "px";
	contents.style.left = (arrPageSize[2] / 2) -  ( sWidth / 2) + ( arrTopLeft[1] )  +"px";
	contents.style.width = sWidth + "px";

	var cIframe = (/MSIE (6|7|8)/).test(navigator.userAgent) ? document.createElement('<iframe name="'+'popLayerIframe' + GMKTpopLayerIndex +'">'): document.createElement('iframe');
	cIframe.setAttribute('name', 'popLayerIframe' + GMKTpopLayerIndex  );
	cIframe.setAttribute('id', 'popLayerIframe' + GMKTpopLayerIndex  );
	cIframe.src = sUrl;
	cIframe.width = sWidth + 'px';
	cIframe.height = sHeight + 'px';
	cIframe.frameBorder = 'no';
	cIframe.scrolling = 'no';

	contents.appendChild(cIframe);

	element.appendChild(contents);

	for ( var i= 0 ; i < popLayer.childNodes.length ; i++ ) popLayer.childNodes[i].childNodes[0].style.display = "none";
	popLayer.appendChild(element);
}
function GmktPopLayerAdd( sUrl, sWidth, sHeight, sClickYn )
{
	GmktPopLayerInit(GmktPopLayerAddOrigin, sUrl, sWidth, sHeight, sClickYn);
}
function GmktPopLayerDelete()
{
	var popLayer = document.getElementById("GmktPopLayer");
	if ( popLayer )
	{
		if(popLayer.lastChild)
		{
			popLayer.removeChild(popLayer.lastChild);
			GMKTpopLayerIndex--;
			if ( GMKTpopLayerIndex == 0 )
				popLayer.style.height = "0px";
		}
		if (popLayer.lastChild)
			popLayer.lastChild.childNodes[0].style.display = "";
	}
	if ( GMKTpopLayerParentReload == "Y" )
		location.reload();
}
function GmktPopLayerDeleteAll()
{
	var popLayer = document.getElementById("GmktPopLayer");
	if ( popLayer)
	{
		while (popLayer.lastChild)
			popLayer.removeChild(popLayer.lastChild);
		GMKTpopLayerIndex = 0;
		popLayer.style.height = "0px";
	}
	if ( GMKTpopLayerParentReload == "Y" )
		location.reload();
}
function GmktPopLayerNull() {}
function GmktPopLayerModify(sUrl, sWidth, sHeight, sClickYn ){
	var IframeLayer     = document.getElementById("popLayerIframe" + GMKTpopLayerIndex );
	var contents = 	document.getElementById("popLayerContents" + GMKTpopLayerIndex );
	if ( contents ) {
		var dimmed = document.getElementById("popLayerDimmed" + GMKTpopLayerIndex );
		var dIframe = document.getElementById("popLayerDimmedIframe" + GMKTpopLayerIndex );
		if ( sClickYn == "Y") {
			dimmed.onclick = GmktPopLayerDelete;
			contents.onclick = GmktPopLayerDelete;
			if ( dIframe ) dIframe.src = "/challenge/neo_include/GmktPopLayerEvent.asp";
		} else {
			dimmed.onclick = GmktPopLayerNull;
			contents.onclick = GmktPopLayerNull;
			if ( dIframe ) dIframe.src = 'about:blank';
		}
	}
	if ( IframeLayer ) {
		if ( sUrl.length > 0 ) IframeLayer.src = sUrl;
		if ( sWidth.length > 0 )IframeLayer.width = sWidth + "px";
		if ( sHeight.length > 0 ) IframeLayer.height = sHeight + "px";
		GmktPopLayerResize("modify");
	}
}
function GmktPopLayerReload()
{
	var IframeLayer     = document.getElementById("popLayerIframe" + GMKTpopLayerIndex );
	if ( IframeLayer ) IframeLayer.contentWindow.location.reload();
}
function GmktPopLayerReloadAll()
{
	var IframeLayer;
	for ( var i= 1 ; i <=GMKTpopLayerIndex ; i++ )
	{
		IframeLayer = document.getElementById("popLayerIframe" + i );
		if ( IframeLayer )
			IframeLayer.contentWindow.location.reload();
	}
}
function GmktPopLayerSetInnerIframe(sUrl){
	var iframe = document.getElementById( 'GmktPopupLayerInnerIframe' );
	if ( !iframe )
	{
		iframe = document.createElement("IFRAME");
		iframe.setAttribute('id', 'GmktPopupLayerInnerIframe' );
		iframe.width = '0px';
		iframe.height = '0px';
		document.body.appendChild(iframe);
	}
	iframe.src = sUrl;
}
function GmktPopLayerAddInner(sUrl, sWidth, sHeight, sClickYn ){
     var iframeDomain = "";
	 if ( document.location.href.split("#").length == 2 )iframeDomain = 'http://' + document.location.href.split("#")[1];
     var iframeUrl = iframeDomain +'/challenge/neo_include/GmktPopLayerGate.asp?mode=add&c=' + sClickYn  + '&h='+sHeight + '&w=' + sWidth + '&url=' + escape(sUrl);
	GmktPopLayerSetInnerIframe(iframeUrl);
}
function GmktPopLayerDeleteInner(){
    var iframeDomain = "";
	if ( document.location.href.split("#").length == 2 )iframeDomain = 'http://' + document.location.href.split("#")[1];
	var iframeUrl = iframeDomain +'/challenge/neo_include/GmktPopLayerGate.asp?mode=delete';
	GmktPopLayerSetInnerIframe(iframeUrl);
}
function GmktPopLayerModifyInner( sUrl, sWidth, sHeight, sClickYn ){
	var iframeDomain = "";
	if ( document.location.href.split("#").length == 2 )iframeDomain = 'http://' + document.location.href.split("#")[1];
    var iframeUrl = iframeDomain +'/challenge/neo_include/GmktPopLayerGate.asp?mode=modify&c=' + sClickYn  + '&h=' +sHeight + "&w=" + sWidth + "&url=" + escape(sUrl);
	GmktPopLayerSetInnerIframe(iframeUrl);
}
function GmktPopLayerReplaceParentInner( sUrl )
{
    var iframeDomain = "";
	if ( document.location.href.split("#").length == 2 )iframeDomain = 'http://' + document.location.href.split("#")[1];
	var iframeUrl = iframeDomain +'/challenge/neo_include/GmktPopLayerGate.asp?mode=replaceparent&url=' + escape(sUrl);
	GmktPopLayerSetInnerIframe(iframeUrl);
}
function GmktPopLayerReloadParentInner()
{
	var iframeDomain = "";
	if ( document.location.href.split("#").length == 2 )iframeDomain = 'http://' + document.location.href.split("#")[1];
	var iframeUrl = iframeDomain +'/challenge/neo_include/GmktPopLayerGate.asp?mode=reloadparent';
	GmktPopLayerSetInnerIframe(iframeUrl);
}
function GmktPopLayerEtcInner( fname, fparam, fscript )
{
	var iframeDomain = "";
	if ( document.location.href.split("#").length == 2 )iframeDomain = 'http://' + document.location.href.split("#")[1];
	var iframeUrl = iframeDomain +'/challenge/neo_include/GmktPopLayerGate.asp?mode=etc&fname=' + fname + '&fscript=' + escape(fscript) + '&fparam=' + fparam;
	GmktPopLayerSetInnerIframe(iframeUrl);
}
function GmktPopLayerScroll()
{
	var popLayer     = document.getElementById("GmktPopLayer");
	if ( popLayer && GMKTpopLayerIndex > 0 )
	{
		var arrPageSize,  element, dimmed, contents ;

		arrPageSize = GmktPageSize();
		popLayer.style.height = arrPageSize[1] + "px";
		popLayer.style.width = arrPageSize[0]+ "px";

		for ( var i= 1 ; i <=GMKTpopLayerIndex ; i++ )
		{
			element = document.getElementById("popLayer" + i );
			if (element)
			{
				element.style.height = arrPageSize[1] + "px";
				element.style.width = arrPageSize[0]+ "px";
			}
			dimmed =  document.getElementById("popLayerDimmed"+ i );
			if ( dimmed )
			{
				dimmed.style.width = arrPageSize[0]+ "px";
				if ( navigator.appVersion.indexOf("MSIE") > -1 &&  arrPageSize[1] > 4096 )
				{
					var dTop = document.body.scrollTop || document.documentElement.scrollTop;
					dimmed.style.height = 4096 + "px";
					if ( ( dTop + 4096 ) <  arrPageSize[1] ) dimmed.style.top = dTop - 1500;
					else dimmed.style.top = ( arrPageSize[1] - 4096 ) + "px";
				} else
					dimmed.style.height = arrPageSize[1] + "px";
			}
		}
	}
}
function GmktPopLayerResize( sMode)
{
	var popLayer     = document.getElementById("GmktPopLayer");
	if ( popLayer && GMKTpopLayerIndex > 0 )
	{
		var arrPageSize,  element, dimmed, contents , ciframe;
		arrPageSize = GmktPageSize();
		arrTopLeft = GmktTopLeft();
		popLayer.style.height = arrPageSize[1] + "px";
		popLayer.style.width = arrPageSize[0]+ "px";

		for ( var i= 1 ; i <=GMKTpopLayerIndex ; i++ )
		{
			element = document.getElementById("popLayer" + i );
			if (element)
			{
				element.style.height = arrPageSize[1] + "px";
				element.style.width = arrPageSize[0]+ "px";
			}
			dimmed =  document.getElementById("popLayerDimmed"+ i );
			if ( dimmed )
			{
				dimmed.style.width = arrPageSize[0]+ "px";
				if ( navigator.appVersion.indexOf("MSIE") > -1 &&  arrPageSize[1] > 4096 )
				{
					var dTop = document.body.scrollTop || document.documentElement.scrollTop;
					dimmed.style.height = 4096 + "px";
					if ( ( dTop + 4096 ) <  arrPageSize[1] ) dimmed.style.top = dTop - 1500;
					else dimmed.style.top = ( arrPageSize[1] - 4096 ) + "px";
				} else
					dimmed.style.height = arrPageSize[1] + "px";
			}
			contents =  document.getElementById('popLayerContents' + i );
			ciframe = document.getElementById("popLayerIframe" + i );
			if ( contents && ciframe )
			{
				if ( sMode == "modify" ) {
					var iTempTop = (arrPageSize[3] / 2) -  (parseInt(ciframe.height) / 2) + ( document.documentElement.scrollTop ||  document.body.scrollTop ) ;
					iTempTop = iTempTop < 0 ? 0 : iTempTop;
					contents.style.top = iTempTop +"px";
				}
				contents.style.left = (arrPageSize[2] / 2) -  (parseInt(ciframe.width) / 2) + ( arrTopLeft[1] )  +"px";
				contents.style.width = parseInt(ciframe.width) + "px";
			}
		}
	}
}
function GmktAddEvent(o, evtName, fun) {
	var oldFun = o[evtName];
	if (typeof oldFun != "function") {
		o[evtName] = fun;
	}else {
		o[evtName] = function() {
			oldFun.call(this);
			fun();
		}
	}
}
GmktAddEvent(window, 'onresize', GmktPopLayerResize);
GmktAddEvent(window, 'onscroll', GmktPopLayerScroll);
