var ObjSearchValue = 0, shortCutDetailContObj = null;
var n = Math.random(), m = n;
var thistop = "T";

if (!window.addEvent) {
	function addEvent(object, eventName, functionName) {
		var method, option = "";

		if (navigator.appVersion.toUpperCase().indexOf("MSIE") > 0) {
			method = "attachEvent";
		} else {
			method = "addEventListener";
			eventName = eventName.replace("on", "");
			option = ", false";
		}

		eval((object ? "object." : "document.") + method + "(\"" + eventName + "\", functionName " + option + ");");
	}
}

if (!window.getCookieVal) {
	function getCookieVal(offset) {
		var endstr = document.cookie.indexOf (";", offset);
		
		if (endstr == -1) endstr = document.cookie.length;
		
		return unescape(document.cookie.substring(offset, endstr));
	}
}

if (!window.getCookie) {
	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 tagfilter(w) {
	var filterTag = new Array("script", "alert");
	
	for (i=0 ; i<filterTag.length ; i++) {
		if ((w.toLowerCase()).indexOf(filterTag[i]) > -1) {
			alert("°Ë»ö¾î·Î [" + filterTag[i] + "]¸¦ Æ÷ÇÔÇÒ ¼ö ¾ø½À´Ï´Ù.");
			return false;
		}
	}

	return true;
}

function BranchSearch() {
	var keywordObj = document.SEARCH.SEARCH_KEYWORD;
	
	if (!keywordObj.style.backgroundImage && !(keywordObj.value == "ÇÑ¹Ì¾àÇ° ¿À¸Þ°¡" || keywordObj.value == "ÇÑ¹Ì¾àÇ° ±Û·çÄÚ»ç¹Î")) {
		w = document.SEARCH.SEARCH_KEYWORD.value;
		
		if (!tagfilter(w)) {
			return;
		} else {
			_goDnshopSearch();
		}
	} else if (keywordObj.value == "ÇÑ¹Ì¾àÇ° ¿À¸Þ°¡" || keywordObj.value == "ÇÑ¹Ì¾àÇ° ±Û·çÄÚ»ç¹Î") {
		adGoUrl_keyword();
	} else {
		adGoUrl(m);
	}
}

function BranchSearchAd() {
	if (!document.CATE_SEARCH.SEARCH_KEYWORD.style.backgroundImage) {
		_cate_formSubmit();
	} else {
		Cate_adGoUrl(n);
	}
}

function eventhref() {
	var domains = document.domain.indexOf("dnshop.com") > -1 ? "http://www.dnshop.com" : "http://dnshop.daum.net";

	location.href = domains + "/front/event/SaveMoney";
}

function shortcutAlarm() {
	var partnerID = getCookie("PARTNERID"), partnerNo = "", object;

//	if (location.toString().indexOf("CartList") > 0) return;

	if (partnerID) partnerNo = partnerID.substring(partnerID.length - 1, partnerID.length);
	if (!partnerNo.replace(/[^0-9]+/, "")) partnerNo = 1;

	if (!partnerID || partnerID == "dnshop_partner_EM" || partnerID == "dnshop_partner_CO" ||
		(partnerID.indexOf("dnshop_partner_A") > -1 && partnerNo >=1 && partnerNo <= 6) ||
		(partnerID.indexOf("dnshop_partner_D") > -1 && partnerNo >=1 && partnerNo <= 4)) {
		shortCutDetailContObj = document.getElementById("Gnb_MarketingBox");

		if (object = document.getElementById("partnerck1")) object.style.display = "block";
		if (object = document.getElementById("GnB_Shortcut_On")) object.style.display = "block";
	} else {
		shortCutDetailContObj = document.getElementById("Gnb_MarketingBox2");

		if (object = document.getElementById("partnerck2")) object.style.display = "block";
		if (object = document.getElementById("GnB_Shortcut_Off")) object.style.display = "block";
	}

	shortCutDetailContObj.setAttribute("orgLeft", shortCutDetailContObj.offsetLeft);
	shortCutDetailContObj.setAttribute("orgTop", shortCutDetailContObj.offsetTop);
}

function shortcutDesc(position, close) {
	var shortcut = document.getElementById("GnB_Shortcut_On");

	if (!shortCutDetailContObj) return;
	if (!shortcut || shortcut.style.display == "none") shortcut = document.getElementById("GnB_Shortcut_Off");

	if (close || shortCutDetailContObj.style.display != "none") {
		shortCutDetailContObj.style.display = "none";
		return;
	}

	if (object = document.getElementById("partnerck1")) object.style.backgroundColor = "transparent";
	if (object = document.getElementById("partnerck2")) object.style.backgroundColor = "transparent";
	if (shortCutDetailContObj.style.position != "relative") shortCutDetailContObj.style.position = "relative";

	if (position == "left") {
		shortCutDetailContObj.style.left = "-190px";
		shortCutDetailContObj.style.top = "130px";
	} else {
		shortCutDetailContObj.style.left = shortCutDetailContObj.getAttribute("orgLeft") + "px";
		shortCutDetailContObj.style.top = shortCutDetailContObj.getAttribute("orgTop") + "px";
	}

	shortCutDetailContObj.style.display = "block";
}

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_changeProp(objName,x,theProp,theValue) { //v6.0
	var obj = MM_findObj(objName);

	if (obj && (theProp.indexOf("style.")==-1 || obj.style)) {
		if (theValue == true || theValue == false) eval("obj."+theProp+"="+theValue);
		else eval("obj."+theProp+"='"+theValue+"'");
	}
}

function showHideCategory(w, h){
	MM_changeProp('Category', '', 'style.width', w, 'DIV');
	MM_changeProp('Category', '', 'style.height' ,h, 'DIV');
}

function openContents() {
	document.getElementById("ShoppWrap").style.paddingTop = 756 + "px";
	document.getElementById("Gnb_Search").style.display = "none";
	document.getElementById("Suggest_Wrap").style.display = "none";
}

function endContents() {
	var Obj = document.getElementById("Gnb_Search");
	var ObjSuggest = document.getElementById("Suggest_Wrap");
	
	if (ObjSearchValue == 1) {
		if ( navigator.appVersion.indexOf("MSIE") != -1 ) {
			if ( navigator.appVersion.indexOf("MSIE 6.0") != -1 && document.getElementById("My_Retention") != null ) {
				Obj.style.marginLeft ="8px";
				ObjSuggest.style.marginLeft ="8px";
			}
			
			Obj.style.top ="82px";
			ObjSuggest.style.top = "101px";
		} else {
			Obj.style.top = "83px";
			ObjSuggest.style.top = "101px";
		}
		
		if (navigator.userAgent.indexOf("Chrome") != -1) {
			Obj.style.top ="71px";
			ObjSuggest.style.top = "101px";
		}
		
		ObjSearchValue = 0;
	} else {
		if (navigator.appName.indexOf("MSIE") != -1) {
			if ( navigator.appVersion.indexOf("MSIE 6.0") != -1 && document.getElementById("My_Retention") != null ) {
				Obj.style.marginLeft ="8px";
				ObjSuggest.style.marginLeft ="8px";
			}
			
			Obj.style.top ="240px";
			ObjSuggest.style.top = "259px";
		} else {
			Obj.style.top = "241px";
			ObjSuggest.style.top = "260px";
		}
		
		if (navigator.userAgent.indexOf("Chrome") != -1) {
			Obj.style.top ="229px";
			ObjSuggest.style.top = "261px";
		}
		
		ObjSearchValue = 1;
	}
	
	Obj.style.display = "block";
	ObjSuggest.style.display = "block";
}

function closeContents() {
	document.getElementById("ShoppWrap").style.paddingTop = 598 + "px";
	document.getElementById("Gnb_Search").style.display = "none";
	document.getElementById("Suggest_Wrap").style.display = "none";
}
