<?
if (!defined("_GNUBOARD_")) exit;

//-- 일반 모드에서 호출 되었습니다.
$bbs_path		= $g4[path];
$adm_path		= ".";
$is_admin_mode	= false;

if($adm_sub_path) {
	//-- adm 하위 디렉토리에서 호출 됐을 때
	$bbs_path		= "../..";
	$adm_path		= "../";
	$is_admin_mode	= true;
}

$begin_time = get_microtime();

@include_once($adm_path."/_common.php");
include_once($g4[path] . "/head.sub.php");
@include_once($adm_path."/admin.config.php");
?>

<script type="text/javascript">
if (!g4_is_ie) document.captureEvents(Event.MOUSEMOVE)
function imageview(id, w, h)
{

    menu(id);

    var el_id = document.getElementById(id);

    //submenu = eval(name+".style");
    submenu = el_id.style;
    submenu.left = tempX - ( w + 11 );
    submenu.top  = tempY - ( h / 2 );

    selectBoxVisible();

    if (el_id.style.display != 'none')
        selectBoxHidden(id);
}

function help(id, left, top)
{
    menu(id);

    var el_id = document.getElementById(id);

    //submenu = eval(name+".style");
    submenu = el_id.style;
    submenu.left = tempX - 50 + left;
    submenu.top  = tempY + 15 + top;

    selectBoxVisible();

    if (el_id.style.display != 'none')
        selectBoxHidden(id);
}

// TEXTAREA 사이즈 변경
function textarea_size(fld, size)
{
	var rows = parseInt(fld.rows);

	rows += parseInt(size);
	if (rows > 0) {
		fld.rows = rows;
	}
}
</script>

<script type="text/javascript" src="<?=$g4['path']?>/js/common.js"></script>
<script type="text/javascript" src="<?=$g4['path']?>/js/sideview.js"></script>
<script type="text/javascript" src="<?=$g4['path']?>/zm.extend/js/common.js"></script>
<script type="text/javascript">
var save_layer = null;
function layer_view(link_id, menu_id, opt, x, y)
{
    var link = document.getElementById(link_id);
    var menu = document.getElementById(menu_id);

    //for (i in link) { document.write(i + '<br/>'); } return;

    if (save_layer != null)
    {
        save_layer.style.display = "none";
        selectBoxVisible();
    }

    if (link_id == '')
        return;

    if (opt == 'hide')
    {
        menu.style.display = 'none';
        selectBoxVisible();
    }
    else
    {
        x = parseInt(x);
        y = parseInt(y);
        menu.style.left = get_left_pos(link) + x + 'px';
        menu.style.top  = get_top_pos(link) + link.offsetHeight + y + 'px';
        menu.style.display = 'block';
    }

    save_layer = menu;
}
</script>

<link rel="stylesheet" href="<?=$g4['admin_path']?>/admin.style.css" type="text/css">
<link rel="stylesheet" href="<?=$g4['admin_path']?>/admin.head.style.css" type="text/css">
<style>
footer		{ clear:both; }

.cssbtn		{ height:35px; border:0px solid; background-color:#4E566E; margin:0 5px 1px 5px; letter-spacing:-1px; cursor:pointer; font-weight:700; }
.cssbtn1	{ color:#DDDFE3; }		/* 기본환경, 회원, 게시판 */
.cssbtn2	{ color:#FFFFFF; }		/* 지음빌더 */
.cssbtn_bg	{ background:#3A4053; }	/* 선택 된 메뉴 배경 */

#csshelp1	{ border:0px; background:#FFFFFF; padding:6px; }		/* 도움말 풍선 */
#csshelp2	{ border:1px solid #6A8BAB; border-radius:4px; padding:0px; }
#csshelp3	{ background:#EEF4F9; padding:3px 10px 10px 10px; border-radius:4px; width:300px; color:#39648F; line-height:120%; text-align:left; font-family:나눔고딕; }

#admtitle	{ color:#3A4052; font-weight:bold; font-size:1.12em; text-align:center; margin:2px; padding:5px; }
a			{ cursor:hand; }

.line		{ margin:0; padding:0; border-top:1px solid #E3E3E3; border-bottom:1px solid #fff; }

.nav_hide	{ display:none; }

/* 공통. 검색 버튼 */
input.bttn_search	{ background:#F3F3F3 url("<?=$g4[path]?>/adm/img/icon_search.png") no-repeat 5px; color:#343434; border-radius:3px; border:1px solid #9E9E9E; padding:7px 5px 5px 25px; cursor:pointer; }
input.bttn_search:hover	{ border:1px solid #64B564; color:#64B564; }
/* 왼쪽 배경 */
body	{ background:url("<?=$g4[path]?>/adm/img/bg_left.gif") repeat-y; }
</style>

<body>
<? 
//-- 현재 페이지가 포함 된 메뉴의 키 값을 구함
foreach($menu as $k=>$v){
	for($j = 1; $j < count($menu[$k]); $j++) {
		if(strpos($menu[$k][$j][2], $_SERVER[PHP_SELF])) {
			$menukey	= $k;
			$menurow	= $j;
		}
	}
}
unset($k);
unset($v);

foreach($menu as $key=>$val){
	foreach($menu[$key] as $k=>$v){
		$auth_menu[$menu[$key][$k][0]] = $menu[$key][$k][1];
	}
}


$nav_hide	= "";
//-- 탑 메뉴 -- 
ksort($menu);
?>
<a name='gnuboard4_admin_head'></a>
<div id="admin_left">
	<div class="txt_admin">
		<a href='<?=$g4['path']?>/adm'><img src='<?=$g4['admin_path']?>/img/txt_admin.gif' border=0></a>
	</div>
	<div class="goto">
		<a href='<?=$g4['path']?>/' title="HOME">홈페이지</a>
		<a href='<?=$g4['bbs_path']?>/logout.php' title="Logout">로그아웃</a>
	</div>


	<div>
<?	if(($sub_menu == "300100") || ($bo_table)) {
		//-- 게시판 목록 전체 불러오기
		include_once("zm.board_all_list.php");
		$nav_hide	= "nav_hide";		//-- 메뉴 안 보이게
	}?>
	</div>


	<? //-- mene begig ?>
	<nav class="<?=$nav_hide?>">
<?	$i	= 0;
	$crtidx	= -1;
	foreach($menu as $k=>$v) :
		if($menukey == $k)	{ $crrt_mn	= "currentmenuc"; $crtidx = $i; }
		else				$crrt_mn	= "currentmenu";
?>
		<div class="menugroup">
		<div class="mngrp"><a href="" class='<?=$crrt_mn?>'><?=$menu[$k][0][1]?></a></div>
<?		if($menu[$k][1][1]) : //-- 서브 메뉴가 있다면 
			$l	= 0; ?>
			<div class="mnsub">
				<ul class="ulsub">
<?				for($j = 1; $j < count($menu[$k]); $j++) :		//-- 서브 메뉴
					if($is_admin == "super" || $auth[$menu[$k][$j][0]]) :
						$l++;
						if(($menukey == $k) && ($l == $menurow)) $crrt_row = "currenta"; else $crrt_row = "";
						if($menu[$k][$j][0] == "-") : ?>
							<li class="menuline"></li>
<?						else : ?>
							<li><a href="<?=$menu[$k][$j][2]?>" class="<?=$crrt_row?>"><?=$menu[$k][$j][1]?></a></li>
<?						endif; 
					endif; ?>
<?				endfor; ?>
				</ul>
			</div> <? //-- end mnsub ?>
			<div class="<?=($l>5)?"":"nomore"?> morebox morehidden">▼</div>
		</div> <? //-- end menugroup ?>
<?		endif;
		$i++;
	endforeach; ?>
	</nav>

<script>
var sub_height	= 100;		//-- 서브 메뉴 접었을 때 높이
var crtidx	= <?=$crtidx?>;	//-- 현재 메뉴 번호
$(document).ready(function(){
	if(crtidx >= 0){
		//-- 현재 메뉴 펼쳐 놓기
		var sub_h	= $("div.menugroup ul.ulsub").eq(crtidx).height();	//-- 메뉴 높이
		$("div.mnsub").eq(crtidx).css("height", sub_h+"px");	//-- 펼치기
		$("div.menugroup div.morebox").eq(crtidx).html("▲");
	}
	fix_rightw();

});
$(window).resize(function(){
	//-- 창크기 변하면 오른쪽 문서 영역도 변경
	fix_rightw();
});
function fix_rightw(){
	//-- 오른쪽 문서 영역 화면 폭에 맞추기
	var doc_w	= $(document).width();
	right_w	= doc_w - 260;
	$("div#admin_right").css("width", right_w+"px");
}
/* 펼치기 */
$("div.menugroup").each(function(index){ ; //-- more 보이기
	$(this).mouseover(function() {
		var cn = $("div.menugroup div.morebox").eq(index).attr("class");
		//-- 펼치기 버튼 보이지 않을 때는
		if(cn.match('nomore')) return false;

		$("div.menugroup div.morebox").eq(index).addClass("more");
		$("div.menugroup div.morebox").eq(index).removeClass("morehidden");
	});
});
$("div.menugroup").each(function(index){ ; //-- more 감추기
	$(this).mouseout(function() {
		$("div.menugroup div.morebox").eq(index).addClass("morehidden");
		$("div.menugroup div.morebox").eq(index).removeClass("more");
	});
});
$("div.menugroup div.morebox").each(function(index){ ; //-- 현재 이벤트 발생한 클래스 순서
	var sub_h	= $("div.menugroup ul.ulsub").eq(index).height();	//-- 메뉴 높이
	$(this).click(function() {
		if($("div.menugroup div.mnsub").eq(index).height() > sub_height) {
			$("div.mnsub").eq(index).css("height", sub_height+"px");	//-- 줄이기
			$("div.menugroup div.morebox").eq(index).html("▼");
		}else{
			$("div.mnsub").eq(index).css("height", sub_h+"px");	//-- 펼치기
			$("div.menugroup div.morebox").eq(index).html("▲");
		}
	});
});
</script>
</div><? //-- end of #admin left ?><div id="admin_right">
<script>
$(function(){
	setTimeout(timechk, 1000);

	//-- 메뉴 그룹
	$("#admin_right div.topmenu div.menu_gp").mouseover(function(){
		$("#admin_right div.topmenu div.menu_gp ul").css("display", "block");
		$("#admin_right div.topmenu div.menu_sub ul").css("display", "none");
	});
	$("#admin_right div.topmenu div.menu_gp ul").mouseout(function(){
		$("#admin_right div.topmenu div.menu_gp ul").css("display", "none");
	});
	//-- 서브메뉴
	$("#admin_right div.topmenu div.menu_sub").mouseover(function(){
		$("#admin_right div.topmenu div.menu_sub ul").css("display", "block");
		$("#admin_right div.topmenu div.menu_gp ul").css("display", "none");
	});
	$("#admin_right div.topmenu div.menu_sub ul").mouseout(function(){
		$("#admin_right div.topmenu div.menu_sub ul").css("display", "none");
	});
});

function timechk(){
	var dt	= new Date();
	var dttm	=
		pastezr(dt.getHours(), 2) + ":" +
		pastezr(dt.getMinutes(), 2) + ":" +
		pastezr(dt.getSeconds(), 2);

	$("div.topmenu_right div.today span").html(dttm);
	setTimeout("timechk()", 1000);
}
function pastezr(n, dg){
	var zr = '';
	n = n.toString();

	if(n.length < dg) {
		for(i = 0; i < dg - n.length; i++) zr += '0';
	}
	return zr + n;
}
</script>

<div class="topmenu">
	<div class="topmenu_left">
		<div><img src="<?=$g4[path]?>/adm/img/icon_menu.gif"></div>
		<div class="menu_gp">
<?		if($menukey) :?><a><?=$menu[$menukey][0][1]?></a>
<?		else : ?><a href="<?=$g4[path]?>/adm/">관리자 홈</a><?endif; ?>
			<ul>
<?			foreach($menu as $k => $v) : ?>
				<li><a href="<?=$menu[$k][1][2]?>"><?=$menu[$k][0][1]?></a></li>
<?			endforeach; ?>
			</ul>
		</div>
		<div class="sub">></div>
		<div class="menu_sub">
<?		if($menukey) : ?><a><?=$menu[$menukey][$menurow][1]?></a>
			<ul class="ul_submenu">
<?			for($i = 1; $i < count($menu[$menukey]); $i++) : 
				if($menu[$menukey][$i][0] == "-") : ?>
				<li class="subline"></li>
<?				else : ?>
				<li><a href="<?=$menu[$menukey][$i][2]?>"><?=$menu[$menukey][$i][1]?></a></li>
<?				endif; ?>
<?			endfor; ?>
			</ul>
<?		else : ?><a>보고서</a><?endif; ?>
			
		</div>
	</div> <?//-- end of topmenu_left?>
	<div class="topmenu_right">
<?
	//-- 상단 정보
	$today1		= date("Y-m-d", $g4[server_time]);
	$today2		= date("H:i:s", $g4[server_time]);
?>
		<div class="today"><img src="<?=$g4[path]?>/adm/img/icon_time.gif" align="middle"> <?=$today1?> <span><?=$today2?></span></div>
		<div class="ip">IP <?=$_SERVER[REMOTE_ADDR]?></div>

<?
	$nowdate	= date("Y-m-d H:i:s", $g4[server_time] - 86400);
	if($nowdate > $zm_config[db_backupdate]) $overday	= true; else $overday = false;

	if($overday)	$backupcss	= "overday1";			//-- 마지막으로 백업한지 하루가 지남
	else			$backupcss	= "overday0";
?>
		<div class="dbbackupdate" onclick="zm_gourl('./zm.mysql_backup.php');">
			<a href="./zm.mysql_backup.php" class="<?=$backupcss?>">마지막 DB 백업한 날짜 <?=$zm_config[db_backupdate]?></a>
		</div>
	</div>	<?//-- end of topmenu_right?>
</div>	<? //-- end of topnemu ?>

<div id="wrap"><? //-- 내용 시작 ?>
<?=zm_service("add-on", "scroll")?>