/*
	////////////////////////////////
	//Nate GNB v2.0 by Noda.      //
	//Last Mod Date : 2009.02.24  //
	////////////////////////////////
*/
classNateGNB = function(arrNateGnbRSInfo) {
	var self = this;
	var bAllListOpen = false; //default : false = closed
	this.AllListOpen = function() { return bAllListOpen }
	function init() { writeGnb(); }
	init();
	function getCookie(name) {
		var cname = name + "=";
		var dc = document.cookie;
		if (dc.length > 0) {
			begin = dc.indexOf(cname);
			if (begin != -1) {
				begin += cname.length; end = dc.indexOf(";", begin);
				if (end == -1)
					end = dc.length;
				return unescape(dc.substring(begin, end));
			}
		}
		return null;
	}

	this.showMoreLayer = function() {
		self.nc('NGA09');
		if (!bAllListOpen) {
			document.getElementById("btnNateGnbAllListLi").className = "view_more open";
			document.getElementById("nateGnbAllList").style.display = "block";
			bAllListOpen = true;
		}
		else {
			document.getElementById("btnNateGnbAllListLi").className = "view_more";
			document.getElementById("nateGnbAllList").style.display = "none";
			bAllListOpen = false;
		}
	}
	this.closeMoreLayer = function() {
		document.getElementById("btnNateGnbAllListLi").className = "view_more";
		document.getElementById("nateGnbAllList").style.display = "none";
		bAllListOpen = false;
	}

	this.nc = function(regionId, redirectUrl, target, option) {
		var img = new Image();
		img.src = 'http://statclick.nate.com/stat/statclick.tiff?cp_url=[click_ndr.nate.com/??ndrpageid=na1&ndrregionid=' + regionId + ']';
		if (redirectUrl == null) return;
		if (target != null) {
			if (option != null)
				window.open(redirectUrl, target, option);
			else
				window.open(redirectUrl, target);
		}
		else
			location.href = redirectUrl;
	}

	function writeGnb() {
		var nRsLength = 0;
		//RS길이 검증
		if (arrNateGnbRSInfo == null || arrNateGnbRSInfo == undefined) {
			arrNateGnbRSInfo = []; //강제 초기화
			nRsLength = 0;
		}

		if (arrNateGnbRSInfo.length > 3)
			nRsLength = 3; //3개보다 많으면 처음 3개만 프린트
		else
			nRsLength = arrNateGnbRSInfo.length;

		var NAME = getCookie("n_");

		//CSS
		var style = '<style type="text/css">';
		style += '#txt_GNB { position:relative; float:right; margin-top:1px; word-wrap:normal !important; }';
		style += '#textGnb p, #textGnb ul, #textGnb li, #textGnb dl, #textGnb dd { margin:0; padding:0; font-family:돋움, Dotum, AppleGothic, sans-serif; }';
		style += '#txt_GNB ul.menu_gnb { float:left; margin:1px 0 0 0; padding:0; }';
		style += '#txt_GNB ul.menu_gnb li { float:left; list-style:none; padding:3px 5px 0 5px; height:auto; background:url(http://natesf.kr/img_v2/gnb/img_txtgnb.gif) no-repeat right -53px; letter-spacing:-1px; font-size:8pt; font-family:"돋움",Dotum, AppleGothic, sans-serif; line-height:11px; }';
		style += '#txt_GNB ul.menu_gnb li.rs_end { font-size:8pt; padding:3px 9px 0 4px; background-position: right -39px; }';
		style += '#txt_GNB ul.menu_gnb li.view_more { padding:3px 21px 0 4px; background:url(http://natesf.kr/img_v2/gnb/img_txtgnb.gif) no-repeat -5px -21px; cursor:pointer; color:#444 !important; }';
		style += '#txt_GNB ul.menu_gnb li.open { background-position:-5px 0; }';
		style += '#txt_GNB ul.menu_gnb li.log_status a { text-indent:-9999px; }';
		style += '#txt_GNB ul.menu_gnb li a { font-family:"돋움",Dotum, AppleGothic, sans-serif; font-size:8pt !important; color:#444 !important; text-decoration:none; text-align:left; overflow:hidden; }';
		style += '#txt_GNB ul.menu_gnb li a:hover { font-size:8pt !important; color:#4488ee !important; text-decoration:underline; }';
		style += '#txt_GNB div.log_status { float:left; }';
		style += '#txt_GNB div.log_status a.login { display:block; width:38px; height:17px; background:url(http://natesf.kr/img_v2/gnb/img_txtgnb.gif) no-repeat 0 -71px; text-indent:-9999px; text-align:left; overflow:hidden; }';
		style += '#txt_GNB div.log_status a.logout { display:block; width:48px; height:17px; background:url(http://natesf.kr/img_v2/gnb/img_txtgnb.gif) no-repeat 0 -90px; text-indent:-9999px; text-align:left; overflow:hidden; }';
		style += '#txt_GNB .gnbAllList { position:absolute; top:18px; right:0; padding:0; width:204px; height:66px; background:#FFF; border:2px solid #c6c6c6; }';
		style += '*html #txt_GNB .gnbAllList { position:absolute; top:18px; right:0; padding:0; width:125px; height:35px; }';
		style += '#txt_GNB ul.service_list { float:left; margin:9px 6px 2px 10px; padding:0; width:186px; display:inline; }';
		style += 'html>body #txt_GNB ul.service_list { float:left; margin:8px 15px 0 10px; padding:0; width:185px; height:22px; }';
		style += '#txt_GNB ul.service_list li { float:left; padding:0; list-style:none; height:19px; background:none; text-align:left; letter-spacing:-1px; line-height:14px; font-size:8pt; }';
		style += '#txt_GNB ul.service_list li.col_01 { width:55px; }';
		style += '#txt_GNB ul.service_list li.col_02 { width:38px; }';
		style += '#txt_GNB ul.service_list li.col_03 { width:38px; }';
		style += '#txt_GNB ul.service_list li.col_04 { width:53px; }';
		style += '#txt_GNB ul.service_list li.link_egloos { height:19px; background:url(http://natesf.kr/img_v2/gnb/img_txtgnb.gif) no-repeat -2px -111px; }';
		style += '#txt_GNB ul.service_list li.view_all { background:url(http://natesf.kr/img_v2/gnb/img_txtgnb.gif) no-repeat 42px -136px; }';
		style += '#txt_GNB ul.service_list li.view_all a { color:#4488ee !important; }';
		style += '#txt_GNB ul.service_list li a { font-family:"돋움",Dotum, AppleGothic, sans-serif; font-size:8pt !important; text-decoration:none; color:#555 !important; }';
		style += '#txt_GNB ul.service_list li a:hover { color:#4488ee !important; text-decoration:underline; }';
		style += '* html #txt_GNB ul.menu_gnb li, * html #txt_GNB ul.menu_gnb li a { line-height:normal; }';
		style += '*:first-child+html #txt_GNB ul.menu_gnb li, *:first-child+html #txt_GNB ul.menu_gnb li a { line-height:normal; }';
		style += '</style>';
		document.write(style);
		document.write(style);
		var strHtml = "";
		var strLoginUrl = "http://xo.nate.com/login.jsp?redirect=http://www.nate.com";
		strHtml += '<div id="txt_GNB">';
		strHtml += '	<ul class="menu_gnb">';
		for (var i = 0; i < nRsLength; i++) {
			if ((i + 1) == nRsLength)
				strHtml += '		<li class="rs_end"><a target="_top" href="' + arrNateGnbRSInfo[i].url + '">' + arrNateGnbRSInfo[i].title + '</a></li>';
			else
				strHtml += '		<li><a target="_top" href="' + arrNateGnbRSInfo[i].url + '">' + arrNateGnbRSInfo[i].title + '</a></li>';
		}

		strHtml += '		<li><a target="_top" href="http://mail.nate.com/" onclick="NateGNB.nc(\'NGA01\')">메일</a></li>';
		strHtml += '		<li><a target="_top" href="http://news.nate.com/" onclick="NateGNB.nc(\'NGA02\')">뉴스</a></li>';
		strHtml += '		<li><a target="_top" href="http://ask.nate.com/" onclick="NateGNB.nc(\'NGA03\')">지식</a></li>';
		strHtml += '		<li><a target="_top" href="http://pann.nate.com" onclick="NateGNB.nc(\'NGA04\')">판</a></li>';
		strHtml += '		<li><a target="_top" href="http://mobile.nate.com/" onclick="NateGNB.nc(\'NGA05\')">폰꾸미기</a></li>';
		strHtml += '		<li><a target="_top" href="http://shopping.nate.com/" onclick="NateGNB.nc(\'NGA06\')">쇼핑</a></li>';
		strHtml += '		<li><a target="_top" href="http://game.nate.com/" onclick="NateGNB.nc(\'NGA07\')">게임</a></li>';
		strHtml += '		<li id="btnNateGnbAllListLi" class="view_more">더보기</li>';
		strHtml += '	</ul>';
		strHtml += '	<div class="log_status">';

		if (NAME == null || NAME == "") {
			var r_url = "";
			try {
				r_url = r_urlFilter(parent.document.location.href);
			}
			catch (e) { }

			var strLoginUrl = "";
			var len = r_url.lastIndexOf("#");
			if (len > 0) r_url = r_url.substring(0, len);
			if (r_url.indexOf("/logout.jsp") > 0) strLoginUrl = "http://xo.nate.com/login.jsp?redirect=http://www.nate.com";
			else if ((r_url.indexOf("/notfound.jsp") < 0) && (r_url.indexOf("/login.jsp") < 0) && (r_url.indexOf("/cplogin.jsp") < 0))
				strLoginUrl = "http://xo.nate.com/login.jsp?redirect=" + r_urlFilter(r_url);
			strHtml += '		<a class="login" title="로그인 버튼" target="_top" href="' + strLoginUrl + '">로그인</a>';
		}
		else
			strHtml += '		<a class="logout" title="로그아웃 버튼" target="_top" href="http://xo.nate.com/logout.jsp">로그아웃</a>';

		strHtml += '	</div>';
		strHtml += '	<div id="nateGnbAllList" class="gnbAllList" style="display:none;">';
		strHtml += '		<ul class="service_list">';
		strHtml += '			<li class="col_01"><a target="_top" title="네이트온 바로가기" href="http://nateon.nate.com/" onclick="NateGNB.nc(\'NGB01\')">네이트온</a></li>';
		strHtml += '			<li class="col_02"><a target="_top" title="책 바로가기" href="http://book.nate.com/" onclick="NateGNB.nc(\'NGB02\')">책</a></li>';
		strHtml += '			<li class="col_03"><a target="_top" title="사전 바로가기" href="http://alldic.nate.com" onclick="NateGNB.nc(\'NGB03\')">사전</a></li>';
		strHtml += '			<li class="col_04"><a target="_top" title="인기검색어 바로가기" href="http://search.nate.com/keyword" onclick="NateGNB.nc(\'NGB04\')">인기검색어</a></li>';
		strHtml += '			<li class="col_01"><a target="_top" title="부동산 바로가기" href="http://estate.nate.com/" onclick="NateGNB.nc(\'NGB05\')">부동산</a></li>';
		strHtml += '			<li class="col_02"><a target="_top" title="증권 바로가기" href="http://stock.nate.com/" onclick="NateGNB.nc(\'NGB06\')">증권</a></li>';
		strHtml += '			<li class="col_03"><a target="_top" title="클럽 바로가기" href="http://club.nate.com/" onclick="NateGNB.nc(\'NGB07\')">클럽</a></li>';
		strHtml += '			<li class="col_04 link_egloos"><a target="_blank" title="이글루스 바로가기" href="http://www.egloos.com" onclick="NateGNB.nc(\'NGB08\')">이글루스</a></li>';
		strHtml += '			<li class="col_01"><a target="_top" title="영화 바로가기" href="http://movie.nate.com/" onclick="NateGNB.nc(\'NGB09\')">영화</a></li>';
		strHtml += '			<li class="col_02"><a target="_top" title="만화 바로가기" href="http://comics.nate.com" onclick="NateGNB.nc(\'NGB10\')">만화</a></li>';
		strHtml += '			<li class="col_03"><a target="_top" title="리뷰 바로가기" href="http://review.nate.com" onclick="NateGNB.nc(\'NGB11\')">리뷰</a></li>';
		strHtml += '			<li class="col_04 view_all"><a target="_top" title="전체보기 바로가기" href="http://www.nate.com/sitemap/index.htm" onclick="NateGNB.nc(\'NGB12\')">전체보기</a></li>';
		strHtml += '		</ul>';
		strHtml += '	</div>';
		strHtml += '</div>';
		document.write(strHtml);
	}

	function r_urlFilter(targetText) {
		var description = targetText;
		description.replace(/</g, "&lt;").replace(/>/g, "&gt;");
		description.replace(/[\"\'][\s]*javascript:(.*)[\"\']/g, "\"\"");
		description = description.replace(/script(.*)/g, "");
		description = description.replace(/eval\((.*)\)/g, "");
		return description;
	}
}

if (document.addEventListener)
	document.addEventListener('click', mouseDownNateGNBEventHandler, false);
else if (document.attachEvent)
	document.attachEvent('onclick', mouseDownNateGNBEventHandler);
	
function mouseDownNateGNBEventHandler(e) {
	try
	{
		var target = (e.srcElement || e.target);
		if (target.id == 'btnNateGnbAllListLi')
			NateGNB.showMoreLayer();
		else
			NateGNB.closeMoreLayer();
	}catch(e){}
}


/*
	////////////////////////////////
	//Nate GNB v2.0 by Noda.      //
	//Last Mod Date : 2009.02.24  //
	////////////////////////////////
*/
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////