//*************************************************************
//**		FILE. : header.js
//**		AUTH. : ±è¹Î¼®
//**		DESC. : Çì´õ
//** 
//**		HISTORY
//**		¼öÁ¤ÀÚ     ¼öÁ¤ÀÏ       ¼öÁ¤³»¿ë
//**		========   ==========   ===============
//**        ±è¹Î¼®     2007-04-16   ÃÖÃÊÀÛ¼º
//**        ÀÌÇØ¹Î     2008-08-13   Ä«Å×°í¸® ¸®´º¾ó
//** 
//*************************************************************

//Y-SHOPÈ¸¿øÀüÈ¯ 20%ÄíÆùÁö±Þ ÀÌº¥Æ®
//2009-07-31 By SEO
function doYShopEventPopup()
{
	popCenterWin("https://www.dcx.co.kr/event/yshop/step1.asp", "yshop", "393", "517", "no");
}

//º¸¾È¼­¹ö Àû¿ëÀ¯¹« °Ë»ç
var sslChk = document.URL.substring(5,4);
var getNowURLPath = "http://";
if(sslChk == "s") {
	getNowURLPath = "https://"
}

//¿À´Ãº» »óÇ° ½ºÅ©¸³Æ® ½ÃÀÛ -----------------------------------------------------------------------
var objLayers = new Array(2);
var blnViewLayer = new Array(2);

blnViewLayer[1] = false;
blnViewLayer[2] = false;

if(document.all) {
	doc = "document.all";
	sty = ".style";
	htm = ""
} else if(document.layers) {
	doc = "document";
	sty = "";
	htm = ".document"
}

function outLayer(seq) {
	objLayers[seq].display="none";
}

function viewLayer(seq) {
	if(!blnViewLayer[seq]){
		blnViewLayer[seq] = true;
		getTodaysItem(seq, 1);
	}
	objLayers[seq].display="block";
}

//¸®½ºÆ®
function getTodaysItem(gb, npage) {
	if(document.URL.indexOf("www")!=-1)
		var urlpath2="www.dcx.co.kr/xml/hearderTodayItem.asp"
	else
		var urlpath2="dcx.co.kr/xml/hearderTodayItem.asp"  

	var xmlHttp = createXMLHttpRequest();
	var gbText = "";
	
	if(npage + "" == "undefined") {
		npage = gb;
		gb = 2;
	}
	if(gb == 1)      gbText = "wishListLayer";
	else if(gb == 2) gbText = "todayItemLayer";
	
	xmlHttp.open("POST", getNowURLPath + urlpath2, true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
	xmlHttp.send("gb="+gb+"&npage="+npage);
	xmlHttp.onreadystatechange = function() {
		/*
		alert("xmlHttp.readyState : " + xmlHttp.readyState + "\n"
			+ "xmlHttp.status : " + xmlHttp.status + "\n"
		);
		*/
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				/*µ¥ÀÌÅÍ Ã³¸® ½ÃÀÛ*/
				var str = xmlHttp.responseXML.getElementsByTagName("MsgList")[0].firstChild.data;
				var divMsg = document.getElementById(gbText);
				//alert(str);
				divMsg.innerHTML = str;	
				/*µ¥ÀÌÅÍ Ã³¸® ³¡*/															
			}
		}
	}
}
//¿À´Ãº» »óÇ° ½ºÅ©¸³Æ® ³¡ -----------------------------------------------------------------------

//³»°ü½ÉÇ°¸ñ ¾ó·µÃ¢
function mypro_conf(){
	var ReturnUrl;
	var strnowpage = location.href
	var tmpfirstIndex = strnowpage.indexOf("goUrl=")
	var tmplastIndex = strnowpage.length
	if(strnowpage.indexOf("goUrl=") >= 0){
		ReturnUrl = strnowpage.substring(tmpfirstIndex + 6, tmplastIndex)
	}
	else{
		ReturnUrl = escape(location.href);
	}  
	var abcd = "·Î±×ÀÎÀÌ ÇÊ¿äÇÑ ¼­ºñ½ºÀÔ´Ï´Ù.      "+"\n\n"+"·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?"; 
	var con = confirm(abcd);
	if(con==true){
		url="https://www.dcx.co.kr/login/dcx_login.asp?goUrl="+ReturnUrl;
		location.href=url;
	}
}

//·Î±×¾Æ¿ô
function setLogOut(){
	popCenterWin("/login/popup_logout.asp", 'popInfo', 383, 353,"no");
}

/*
//ÀüÃ¼Ä«Å×°í¸®³»¿ë °¡Á®¿À±â
function getAllCategory() {
	var xmlHttp = createXMLHttpRequest();
	
	xmlHttp.open("POST", "/xml/headerCategory_xml.asp", true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
	xmlHttp.send("");
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				//µ¥ÀÌÅÍ Ã³¸® ½ÃÀÛ			
				var str = xmlHttp.responseXML.getElementsByTagName("MsgList")[0].firstChild.data;			  
				var divMsg = document.getElementById("allCategory");
				blnGotAllcategory = true;
				divMsg.innerHTML = str;	
				//µ¥ÀÌÅÍ Ã³¸® ³¡
			}
		}
	}
}
*/

blnGotAllcategory = false;
//ÀüÃ¼Ä«Å×°í¸®º¸±â
function viewAllCategory() {
	if (document.all.allCategory.style.display == "none") {
		/*
		if (window.location.pathname == "/index.asp" || window.location.pathname == "/main.asp" || window.location.pathname == "/index_change.asp" || window.location.pathname == "/") {
			if(!blnGotAllcategory) getAllCategory();
		}
		*/
		document.all.allCategory.style.display = "";
	} else {
		outAllCategory();
	}
}

//ÀüÃ¼Ä«Å×°í¸®º¸±â º¸ÀÌ±â
function overAllCategory() {
	document.all.allCategory.style.display = "";
}

//ÀüÃ¼Ä«Å×°í¸®º¸±â ´Ý±â
function outAllCategory() {
	document.all.allCategory.style.display = "none";
}



/*function AllCategoryLayer_iframe() {
	AllCategoryLayer_reSize();
	setTimeout('AllCategoryLayer_iframe()',200)
}
AllCategoryLayer_iframe();

AllCategoryLayer_reSize();

//ÀüÃ¼Ä«Å×°í¸®·¹ÀÌ¾î ³ôÀÌ ÀÚµ¿Á¶Àý
function AllCategoryLayer_reSize() {
	try {
		var objBody = allCategoryFrame.document.body;
		var objFrame = document.all["allCategoryFrame"];
		ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);

		if (ifrmHeight > 50) {
			objFrame.style.height = ifrmHeight
		}
		else{
			objFrame.style.height = 10;
		}
		objFrame.style.width = '100%'
	}
	catch(e){}
}*/

//»óÇ° °Ë»ö Ã¼Å©
function chkHeaderSrchFrm(){
	String.prototype.trim=function(){
		var str=this.replace(/(\s+$)/g,"");
		return str;
	}
	var headerFrm = document.headerSrchFrm;
	headerConVal = headerFrm.srchKeyword_t.value;
	if(headerConVal == ""){
		alert("°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		headerFrm.srchKeyword_t.focus();
		return false;
	}
	if(headerConVal.trim().length < 1){
		alert("°Ë»öÃ¢¿¡ °ø¹é¸¸ ÀÔ·ÂÇÒ ¼ö ¾ø¾î¿ä!");	
		headerFrm.srchKeyword_t.focus();
		return false;
	}
 	if(headerConVal.length < 2){
		alert("°Ë»ö¾î¸¦ 2ÀÚ ÀÌ»ó ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		headerFrm.srchKeyword_t.focus();
		return false;
	}
	headerFrm.action="/item/item_search_key.asp";
}

//¿À´Ã º» »óÇ° ·¹ÀÌ¾î
document.writeln("<div id='wishListLayer' style='position:absolute;left:expression((document.body.clientWidth) / 2 + 243);margin-top:20px; z-index:1;display: none;'></div>");
document.writeln("<div id='todayItemLayer' style='position:absolute;left:expression((document.body.clientWidth) / 2 + 243);margin-top:20px; z-index:1;display: none;'></div>");

objLayers[1] = eval('document.all["wishListLayer"].style');
objLayers[2] = eval('document.all["todayItemLayer"].style');


function openHeaderCatM(nNo) {
	var objDiv                = document.getElementById("HeaderCatM" + nNo);
	objDiv.style.visibility   = "visible";
} 

function closeHeaderCatM(nNo) {
	var objDiv                = document.getElementById("HeaderCatM" + nNo);
	objDiv.style.visibility   = "hidden"; 
}

function _ID(obj){return document.getElementById(obj)}

function exec_script(src)
{
	var scriptEl = document.createElement("script");
	scriptEl.src = src;
	_ID('dynamic').appendChild(scriptEl);
}

function clickSet(str,gb,lourl){
	
	exec_script("/xml/mainTongIns.asp?menuCD="+ str +"&seq="+ gb);
	document.location.href = lourl;	
}

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();
}