<?
include_once("./_common.php");
/* 2012년 11월 05일 */
if($bo_table){
	if($sca){
		$ed_code = $bo_table."&sca=".$sca;
	}else{
		$ed_code = $bo_table;
	}
	$menu_selection = sql_fetch("select * from xe_menu where link_id = '{$ed_code}' order by code desc;");
	$menucode = $menu_selection[code];
	unset($ed_code);
}else{
	$url_c = str_replace("//", "/", $_SERVER[PHP_SELF]);
	$menu_selection = sql_fetch("select * from xe_menu where link like '%{$url_c}%' order by code desc;");
	if($menu_selection[link_code]){
		$menu_selection[code] = $menu_selection[link_code];
	}
	$menucode = $menu_selection[code];
}
/* 2012년 11월 05일 */
?>

<script type="text/javascript" src="<?=$g4[path]?>/xe/theme/<?=$config[cf_xe_theme]?>/js/xe.script.js"></script>

<div id="top_wrap">
	<div id="top_real">
		<div class="top_left">
			<ul>
				<li class="search"><img src="<?=$g4[path]?>/xe/theme/<?=$config[cf_xe_theme]?>/img/icon_top_search.png" width="51" height="44"></li>
				<li><a href="javascript:bookmarksite('<?=$config[cf_title]?>', 'http://<?=$_SERVER['SERVER_NAME']?>')">북마크하기</a></li>
				<li>|</li>
				<li><a href="<?=$g4['bbs_path']?>/current_connect.php">현재접속자</a></li>
				<li>|</li>
				<li><a href="<?=$g4['bbs_path']?>/new.php">새로올라온글</a></li>
			</ul>
		</div>
		<div class="top_right">
			<ul>
				<li><a href="<?=$g4['path']?>/">홈</a></li>
				<li>|</li>
				<? if (!$member['mb_id']) { ?>
				<li><a href="<?=$g4['bbs_path']?>/login.php?url=<?=$urlencode?>">로그인</a></li>
				<li>|</li>
				<li><a href="<?=$g4['bbs_path']?>/register.php">회원가입</a></li>
				<? } else { ?>
				<li><a href="<?=$g4['bbs_path']?>/logout.php">로그아웃</a></li>
				<li>|</li>
				<li><a href="<?=$g4['path']?>/xe/module/mypage/">마이페이지</a></li>
				<? } ?>
				<? if ($is_admin == "super" || $is_auth) { ?>
				<li>|</li>
				<li><a href="<?=$g4['path']?>/adm/xe/xe_config_form.php"><b>관리자</b></a></li>
				<? } ?>
			</ul>
		</div>
	</div>
</div>

<div id="wrap">
	<div id="header">
		<div class="head_title">
			<div class="head_title_left"><h1><a href="<?=$g4[path]?>"><img src="<?=$g4[path]?>/xe/theme/<?=$config[cf_xe_theme]?>/img/logo_gnuxe.png" width="230" height="53" border="0" alt=""></a></h1></div>
			<div class="head_title_right"><img src="<?=$g4[path]?>/xe/theme/<?=$config[cf_xe_theme]?>/img/banner/top_banner_01.gif" width="525" height="75" border="0" alt=""></div>
		</div>
		<div class="head_menu">
			<ul>
				<?
				/* 2012년 11월 05일 */
				$xe_menu_query = "select * from xe_menu  where length(code)=3 and visible = '1' order by `order` asc";
				$xe_menu_result = mysql_query($xe_menu_query);
				for($xm=0; $xm < $xe_menu=mysql_fetch_array($xe_menu_result); $xm++) {
				if($xm<>"0"){ echo "<li class='bar_01'>|</li>"; } // 2012-11-05 16시 추가
				?>
				<li>
					<a href="<?=$g4[path]?><?if(!$xe_menu[link]){?>#<?}else{ echo $xe_menu[link]; }?>" target="<?=$xe_menu[target]?>">
						<?=$xe_menu[name]?>
					</a>
					<?
					$xe_menu_sub_query = "select * from xe_menu where length(code)>3 and length(code) < 9 and visible = '1' and code like '{$xe_menu[code]}%' order by `order` asc";
					$xe_menuxe_menu_sub_result = mysql_query($xe_menu_sub_query);
					$sm_count = mysql_num_rows($xe_menuxe_menu_sub_result);
					for($xms=0; $xms < $xe_menuxe_menu_sub=mysql_fetch_array($xe_menuxe_menu_sub_result); $xms++) {
					if($xms == "0"){ echo "<ul>"; }
					if($xms<>"0"){ echo "<li class='bar_02'>|</li>"; } // 2012-11-05 16시 추가
					?>
						<li>
							<a href="<?=$g4[path]?><?if(!$xe_menuxe_menu_sub[link]){?>#<?}else{ echo $xe_menuxe_menu_sub[link]; }?>" target="<?=$xe_menuxe_menu_sub[target]?>">
								<?=$xe_menuxe_menu_sub[name]?>
							</a>
						</li>
					<?
					if(($xms+1) == $sm_count){ echo "</ul>"; }
					}?>
				</li>
				<?}
				/* 2012년 11월 05일 */
				?>
			</ul>
		 </DIV>
	</div>

	<div id="container">
		<div class="cnt_left">
			<div class="cnt_line"></div>
			<? echo outlogin("xe_community"); ?>
			<?if($menucode){// 2012-11-05?>
			<div class="cnt_left_sub_menu">
				<?
				$menucode = substr($menucode, 0, 3);
				$query_sub_menu = "select * from xe_menu where code like '{$menucode}%' and length(code) > '3' and `level` <= '{$member[mb_level]}' order by length(code), `order`, code asc";
				$result_sub_menu = mysql_query($query_sub_menu);
				$menu_title = sql_fetch("select * from xe_menu where `code` = '$menucode';");
				?>
				<h2><a href="<?=$g4[path]?><?if(!$menu_title[link]){?>#<?}else{ echo $menu_title[link]; }?>" target="<?=$menu_title[target]?>"><?=$menu_title[name]?></a></h2>
				<ul>
					<?for ($i=0; $i<$sub_menu_row= mysql_fetch_array($result_sub_menu);$i++){?>
					<li>
						<a href="<?=$g4[path]?><?if(!$sub_menu_row[link]){?>#<?}else{ echo $sub_menu_row[link]; }?>" target="<?=$sub_menu_row[target]?>">
							<span>&middot; <?=$sub_menu_row[name]?></span>
						</a>
					</li>
					<?}?>
				</ul>
			</div>
			<?}// 2012-11-05?>
			<div class="cnt_latest">
				<span>커뮤니티 주간베스트</span>
				<? echo day7_latest("xe_7day", "01", 7, 27); ?>
			</div>
			<div class="cnt_left_xe_banner">
				<a href="http://gnumarket.kr/" onclick="window.open(this.href, 'target', ''); return false;" title="그누마켓 홈페이지 이동(새창 열림)"><img src="<?=$g4[path]?>/xe/theme/<?=$config[cf_xe_theme]?>/img/banner/aside_banner_01.gif" width="185" height="88"></a>
			</div>
			<div class="cnt_latest">
				<span><a href="<?=$g4[bbs_path]?>/board.php?bo_table=0101">공지사항</a></span>
				<? echo latest("xe_basic_nodate", "0101", 10, 26);?>
			</div>
			<div class="cnt_latest">
				<span><a href="<?=$g4[bbs_path]?>/board.php?bo_table=0101">자주묻는질문</a></span>
				<? echo latest("xe_basic_nodate", "0101", 10, 26);?>
			</div>
		</div>
		<div id="content">
			<? if($bo_table) { ?>
			<div class="subtitle">
				<div class="sbt_left">
					<img src="<?=$g4[path]?>/xe/theme/<?=$config[cf_xe_theme]?>/img/icon_stroke_32x24.png">
					<span><em><?=($board[bo_subject]?"{$board[bo_subject]}":"메인화면")?></em>
						<? if ($sca) { ?>
						[ <?=$sca?> ]
						<? } ?>
					</span>
				</div>

				<div class="sbt_right">
					<span>
						홈 &gt;
						<?
							if ($bo_table) {
								echo $group[gr_subject];
								echo " &gt;".$board[bo_subject];
							}
							else {
								echo "메인화면";
							}
						?>
					</span>
				</div>
			</div>
			<? } ?>