//========== 쿠키값 처리 함수 S
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {	//while open
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break; 
	}	//while close
	return null;
}
//========== 쿠키값 처리 함수 E

tmp = CatID.substring(0, 2);

// SUBMENU LINE 시작 
var TimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;
var currentimg    = null;

var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

// Open Hidden Layer
function mopen(n)
{
    var mm  = document.getElementById('gnb1_'+n);
    var l = document.getElementById('gnb2_s'+n);
    var sel_img = document.getElementById('gnbimg_'+n);
    if(l)
    {
		sel_img.src='http://image.chosun.com/cs/gnb/forum_menu'+n+'_on.gif';
        mcancelclosetime();
        l.style.display='block';
        if(currentLayer && (currentLayerNum != n)){
            currentLayer.style.display='none';
			currentimg.src='http://image.chosun.com/cs/gnb/forum_menu'+n+'.gif';
			sel_menu();
		}
        currentLayer = l;
        currentitem = mm;
		currentimg = sel_img;
        currentLayerNum = n;
    }
    else if(currentLayer)
    {
        currentLayer.style.display='none';
		currentimg.src='http://image.chosun.com/cs/gnb/forum_menu'+currentLayerNum+'.gif';
		sel_menu();
        currentLayerNum = 0;
        currentitem = null;
        currentLayer = null;
		currentimg = null;
    }
}
// Turn On Close Timer
function mclosetime()
{
    closeTimer = window.setTimeout(mclose, TimeOut);
}
// Cancel Close Timer
function mcancelclosetime()
{
    if(closeTimer)
    {
        window.clearTimeout(closeTimer);
        closeTimer = null;
    }
}
// Close Showed Layer
function mclose()
{
    if(currentLayer && noClose!=1)
    {
        currentLayer.style.display='none';
		currentimg.src='http://image.chosun.com/cs/gnb/forum_menu'+currentLayerNum+'.gif';
        currentLayerNum = 0;
		sel_menu();
        currentLayer = null;
        currentitem = null;
		currentimg = null;
    }
    else
    {
        noClose = 0;
    }
    currentLayer = null;
    currentitem = null;
}
function over_menu(on_menu){
	if(on_menu){
		document.getElementById('gnbimg_'+on_menu).src='http://image.chosun.com/cs/gnb/forum_menu'+on_menu+'_on.gif';
	}else{
		document.getElementById('gnbimg').src='http://image.chosun.com/cs/gnb/forum_menu_on.gif';
	}
}
function out_menu(off_menu){
	if(off_menu){
	document.getElementById('gnbimg_'+off_menu).src='http://image.chosun.com/cs/gnb/forum_menu'+off_menu+'.gif';
	}else{
		document.getElementById('gnbimg').src='http://image.chosun.com/cs/gnb/forum_menu.gif';
	}
sel_menu();
}
function sel_menu(){
	if(tmp)	{
			document.getElementById('gnbimg_'+tmp).src='http://image.chosun.com/cs/gnb/forum_menu'+tmp+'_on.gif';
	}

}
// Close Layer Then Click-out
document.onclick = mclose; 

//로그인 관련 ---
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {	//while open
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break; 
	}	//while close
	return null;
}
//로그인
function loginFrame () {
	//페이지 URL
	var returl = document.location; 
	if (returl == null || returl == ""){
		returl = M_SITE;
	}
	returl = escape(returl);

	var login_url = "https://membership.chosun.com/login/protect_sso/sso_user_info.jsp?returl="+returl;
	var logout_url = "https://membership.chosun.com/login/logout.jsp?returl="+returl;
	var regist_url = "https://membership.chosun.com/join/registUser.jsp?site=chosun";
	var join_url = "https://membership.chosun.com/join/registUser.jsp?act=myindex&site=chosun";
	var idpw_url = "https://membership.chosun.com/join/registUser.jsp?act=idpw&site=chosun";
	var logStr;

	//로그인여부 - 쿠키값 확인
	if (!GetCookie('SMSESSION') || GetCookie('SMSESSION') == "LOGGEDOFF" || !GetCookie('SM_USER')) {
		logStr = "<li><span>ㆍ</span><a href=" + login_url + " target='_top'>로그인</a></li><li><span>ㆍ</span><a href=" + regist_url + " target='_top'>회원가입</a></li><li><span>ㆍ</span><a href=" + idpw_url + " target='_top'>아이디 / 비밀번호 찾기</a></li>";
	}
	else if (!GetCookie('dz_nm') || !GetCookie('dz_info')) {	//20070406 rainy
	var relogin_url = "https://membership.chosun.com/login/protect_sso/sso_user_info.jsp?returl="+returl;
		parent.location.href = relogin_url;
	}
	else {
		logStr = "<li><span class='user_name'>"+unescape(GetCookie('dz_nm'))+"</span>님</li>" ;
		logStr = logStr + "<li><span>ㆍ</span><a href=" + logout_url + " target='_top'>로그아웃</a></li><li><span>ㆍ</span><a href=" + join_url + " target='_top'>정보수정</a></li>";
	}
	
	return logStr;
}
document.write(" \
<style type='text/css'> \
fieldset,img{border:none;} \
hr,legend{display:none;} \
#logo_etc{float:none;clear:both;margin:0;padding:0;height:60px;} \
#logo{position:relative;width:235px;float:left;margin:0 0px 0 19px;display:inline;} \
#logo h1{float:left;font-style:normal;font-size:12px;margin:7px 4px 0 0;} \
#logo h1 img{vertical-align:top;} \
#logo h2{float:left;font-style:normal;font-size:12px;margin-top:7px;} \
#logo h2 img{vertical-align:top;} \
#logo ul#login{position:absolute;top:38px;left:0px;} \
#logo ul#login li{float:left;font-size:11px;color:#666666;} \
#logo ul#login li a{font-size:11px;color:#666666;letter-spacing:-1px;line-height:12px;} \
#logo ul#login li span{color:#333;font-weight:bold;} \
#logo ul#login li span.user_name{color:#666;} \
#lang{float:left;width:55px;margin:0 55px 0 0;line-height:16px;} \
#lang li{margin:2px 0 0 0;padding:0 0 1px 8px;border-bottom:1px solid #cdcdcd;background:url('http://image.chosun.com/cs/gnb/bul_sq_9f.gif') 0 6px no-repeat;} \
#lang li.firstchild{margin:0;padding:0 0 0 6px;} \
#lang li.lastchild{border:none;padding:0 0 0 8px;} \
#tot_search{width:266px;float:left;margin:8px 0 0 0;} \
#tot_search fieldset input{vertical-align:middle;} \
.search_box{position:relative;background:url('http://image.chosun.com/cs/gnb/bg_search.gif') left top no-repeat;margin-right:3px;width:250px;height:24px;} \
.search_box input.search_text{border:none;width:205px;margin:3px 0 2px 3px;font-size:12px;font-family:'Dotum';color:#333;ime-mode:active;} \
.search_box input.search_btn{position:absolute;top:0px;left:217px;} \
.popular_search{float:none;clear:both;margin-top:3px;} \
#top_ban{float:right;width:250px;height:57px;margin:5px 0 -2px 0;padding:0;} \
#gnb_new{float:none;clear:both;position:relative;width:970px;height:39px;margin:0;background:url('http://image.chosun.com/cs/gnb/bg_forum_gnb.gif') left top repeat-x;z-index:2;} \
#gnb1{float:left;margin:9px 0 0 32px;display:inline;} \
#gnb1 li{position:relative;float:left;margin:0;} \
#gnb1 li span{padding:0 15px 0 15px;} \
.gnb2{position:absolute;top:23px;left:0px;display:none;width:100px;padding:14px 0 15px 0;border:2px solid #544ea0;background-color:#fff;overflow:hidden;} \
.gnb2 li{float:none !important;margin:6px 0 0 5px !important;} \
.gnb2 li span{font-weight:bold;color:#999;padding:0 0 0 0 !important;} \
.gnb2 li a{color:#333 !important;;font-weight:normal !important;text-decoration:none !important;} \
.gnb2 li a:hover{text-decoration:underline !important;} \
#gnb3{float:right;margin:8px 10px 0 0;display:inline;} \
#gnb3 li{float:left;} \
#all_ser { top:0px; }\
#all_list{width:270px;text-align:left;} \
</style> \
	<!-- logo_etc --> \
	<div id='logo_etc'> \
		<div id='logo'> \
			<h1><a href='http://www.chosun.com/'><img src='http://image.chosun.com/cs/gnb/logo_chosun_s.gif' alt='chosun.com'></a></h1> \
			<h2><a href='http://forum.chosun.com/'><img src='http://image.chosun.com/cs/gnb/logo_forum.gif' alt='토론마당'></a></h2> \
			<ul id='login'>" +loginFrame()+ "</ul> \
		</div> \
		<ul id='lang'> \
			<li class='firstchild'><a href='http://japanese.chosun.com/' target='_blank'>日本語</a></li> \
			<li><a href='http://english.chosun.com/' target='_blank'>English</a></li> \
			<li class='lastchild'><a href='http://chn.chosun.com/' target='_blank'>中文</a></li> \
		</ul> \
		<div id='tot_search'> \
			<form method='get' action='http://search.chosun.com/search/totalSearch.jsp' target='_blank'> \
				<fieldset> \
					<legend>통합검색</legend> \
					<div class='search_box'><input type='text' name='searchTerm' id='searchTerm' class='search_text' tabindex='1' title='검색어 입력'><input type='image' src='http://image.chosun.com/cs/gnb/gnb_search_btn.gif' class='search_btn' alt='통합검색'></div> \
				<fieldset> \
			</form> \
			<div class='popular_search'> \
				<iframe src='http://news.chosun.com/common/r_search/popular/' title='추천검색어' width='262' height='18' frameborder='0' scrolling='no'></iframe> \
			</div> \
		</div> \
		<div id='top_ban'><noscript><iframe src='http://news.chosun.com/event/GnbIssue/index.html' title='핫이슈 배너' width='250' height='57' frameborder='0' scrolling='no'><\/iframe></noscript> \
		");
		ban_ran = Math.floor(Math.random()*3+1);
		if (ban_ran > 1){
			document.write("<iframe src='http://news.chosun.com/event/GnbIssue/index.html' title='핫이슈 배너' width='250' height='57' frameborder='0' scrolling='no'><\/iframe>");
		} else {
			document.write("<iframe src='http://news.chosun.com/event/GnbPromotion/index.html' title='프로모션 배너' width='250' height='57' frameborder='0' scrolling='no'><\/iframe>");
		}
document.write(" \
	<\/div> \
	<\/div> \
	<!-- logo_etc // --> \
	<!-- gnb --> \
	<div id='gnb_new'> \
		<ul id='gnb1'> \
			<li id='gnb1'><a href='http://forum.chosun.com/'><img src='http://image.chosun.com/cs/gnb/forum_menu.gif' id='gnbimg_0' alt='토론마당홈' onmouseover=\"over_menu('0')\" onmouseout=\"out_menu('0')\"></a><span><img src='http://image.chosun.com/cs/gnb/bar_forum_gnb2.gif' alt=''></span></li> \
			<li id='gnb1_11'><a href='http://forum.chosun.com/bbs.message.list.screen?bbs_id=101100'><img src='http://image.chosun.com/cs/gnb/forum_menu1.gif' id='gnbimg_11' alt='시사발언대' onmouseover=\"over_menu('11')\" onmouseout=\"out_menu('11')\"></a> <span><img src='http://image.chosun.com/cs/gnb/bar_forum_gnb2.gif' alt=''></span></li> \
			<li id='gnb1_13'><a href='http://forum.chosun.com/bbs.reple.bbsList.screen'><img src='http://image.chosun.com/cs/gnb/forum_menu2.gif' id='gnbimg_13' alt='천자토론' onmouseover=\"over_menu('13')\" onmouseout=\"out_menu('13')\"></a><span><img src='http://image.chosun.com/cs/gnb/bar_forum_gnb2.gif' alt=''></span></li> \
			<li id='gnb1_14'><a href='http://forum.chosun.com/bbs.poll.all.list.screen?bbs_id=700100'><img src='http://image.chosun.com/cs/gnb/forum_menu3.gif' id='gnbimg_14' alt='공감토론' onmouseover=\"over_menu('14')\" onmouseout=\"out_menu('14')\"></a><span><img src='http://image.chosun.com/cs/gnb/bar_forum_gnb2.gif' alt=''></span></li> \
			<li id='gnb1_15'><a href='http://forum.chosun.com/history.top.screen'><img src='http://image.chosun.com/cs/gnb/forum_menu15.gif' id='gnbimg_15' alt='베스트토론' onmouseover=\"over_menu('15')\" onmouseout=\"out_menu('15')\"></a><span><img src='http://image.chosun.com/cs/gnb/bar_forum_gnb2.gif' alt=''></span></li> \
		</ul> \
		<ul id='gnb3'> \
			<li><a href='http://photo.chosun.com/'><img src='http://image.chosun.com/cs/gnb/forum_smenu1.gif' alt='포토'></a></li> \
			<li><a href='http://video.chosun.com/'><img src='http://image.chosun.com/cs/gnb/forum_smenu2.gif' alt='동영상'></a></li> \
			<li><a href='http://newsplus.chosun.com/ranking/'><img src='http://image.chosun.com/cs/gnb/forum_smenu3.gif' alt='랭킹'></a></li> \
		</ul> \
	</div> \
	<!-- gnb // --> \
");
sel_menu();