<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

if (G5_IS_MOBILE) {
    include_once(G5_THEME_MOBILE_PATH.'/head.php');
    return;
}

include_once(G5_THEME_PATH.'/head.sub.php');
include_once(G5_LIB_PATH.'/latest.lib.php');
include_once(G5_LIB_PATH.'/outlogin.lib.php');
include_once(G5_LIB_PATH.'/poll.lib.php');
include_once(G5_LIB_PATH.'/visit.lib.php');
include_once(G5_LIB_PATH.'/connect.lib.php');
include_once(G5_LIB_PATH.'/popular.lib.php');

// 메뉴 확장 관련
if(isset($bo_table)) { 
	$cate = "me_link LIKE '%bo_table=".$bo_table ."%'"; 
	$present_row = sql_query("select me_code  from ".$g5['menu_table']." where $cate order by me_order,me_code desc,me_id limit 0,1 "); 
	$total_count = sql_num_rows($present_row); 
	for ($i=0 ; $i < $total_count ; $i++) { 
		$present_row2=sql_fetch_array($present_row); 
	} 
	if (isset($present_row2['me_code'])) $me_code = $present_row2['me_code']; 
	
}else if(isset($co_id)){ 

	$cate = "me_link LIKE '%co_id=".$co_id ."' "; 
	$present_row = sql_query("select me_code  from ".$g5['menu_table']." where $cate order by me_order,me_code desc,me_id limit 0,1 "); 
	$total_count = sql_num_rows($present_row); 
	for ($i=0 ; $i < $total_count ; $i++) { 
		$present_row2=sql_fetch_array($present_row); 
	} 
	if (isset($present_row2['me_code'])) $me_code = $present_row2['me_code']; 
}

?>

<script>
    new WOW().init();
</script>
<script>
    $(function() {
        $("#gnb .gnb_1dli").mouseenter(function() {
            var menuWidth = $("#gnb .gnb_1dli").outerWidth();
            var menuLeft = menuWidth;
            var index = $(this).index();

            for (var i = 0; i <= index - 1; i++) {
                menuLeft += $("#gnb .gnb_1dli").eq(i).outerWidth();
            }
            menuLeft -= $(this).outerWidth();
            $("#nav_bar").stop().animate({
                width: menuWidth,
                left: menuLeft
            }, 300);
        });

        $("#gnb").mouseleave(function() {
            $("#nav_bar").stop().animate({
                width: 0,
                left: 0
            }, 0);
        });
        setInterval(function() {
            if ($(window).scrollTop() >= 90) {
                $("#hd").addClass("scrollBg");
                $("#logo img.logo_pc").attr("src", "<?php echo G5_THEME_IMG_URL ?>/common/logo.png");
            } else {
                $("#hd").removeClass("scrollBg");
                $("#logo img.logo_pc").attr("src", "<?php echo G5_THEME_IMG_URL ?>/common/logo_white.png");
            }
        }, 300);
    });
</script>

<!-- 상단 시작 { -->
<div id="hd">
    <h1 id="hd_h1"><?php echo $g5['title'] ?></h1>

    <div id="skip_to_container"><a href="#container">본문 바로가기</a></div>

    <?php
    if(defined('_INDEX_')) { // index에서만 실행
        include G5_BBS_PATH.'/newwin.inc.php'; // 팝업레이어
    }
    ?>
    <div id="hd_wrapper">
        <div class="inner">
            <div id="mb-open-menu">
                <span class="line1"></span>
                <span class="line2"></span>
                <span class="line3"></span>
            </div>
            <div id="tnb">
                <ul>
                    <?php if ($is_member) {  ?>
                    <li class="register"><a href="<?php echo G5_BBS_URL ?>/member_confirm.php?url=<?php echo G5_BBS_URL ?>/register_form.php"><i class="fa fa-user-circle" aria-hidden="true"></i> 정보수정</a></li>
                    <li class="logout"><a href="<?php echo G5_BBS_URL ?>/logout.php"><i class="fa fa-sign-out" aria-hidden="true"></i> 로그아웃</a></li>
                    <?php if ($is_admin) {  ?>
                    <li class="tnb_admin"><a href="<?php echo G5_ADMIN_URL ?>"><b><i class="fa fa-cog" aria-hidden="true"></i> 관리자</b></a></li>
                    <?php }  ?>
                    <?php } else {  ?>
                    <li class="join"><a href="<?php echo G5_BBS_URL ?>/register.php"><i class="fa fa-user-plus" aria-hidden="true"></i> 회원가입</a></li>
                    <li class="login"><a href="<?php echo G5_BBS_URL ?>/login.php"><b><i class="fa fa-sign-in" aria-hidden="true"></i> 로그인</b></a></li>
                    <?php }  ?>
                    <li class="shop"><a href="https://shop.ddfnd.com" target="_blink"><i class="fa fa-user-plus" aria-hidden=true"></i>쇼핑몰</a></li>
                </ul>
            </div>
            
           
            <div id="logo">
                <a href="<?php echo G5_URL ?>">
                    <img class="logo_pc" src="<?php echo G5_THEME_IMG_URL ?>/common/logo_white.png" alt="<?php echo $config['cf_title']; ?>">
                    <img class="logo_mobile" src="<?php echo G5_THEME_IMG_URL ?>/common/logo_white.png" alt="<?php echo $config['cf_title']; ?>">
                </a>
            </div>


            <nav id="gnb">
                <h2>메인메뉴</h2>
	              <div class="gnb_wrap">
					        <ul id="gnb_1dul">
					            <?php
					            $sql = " select *
					                        from {$g5['menu_table']}
					                        where me_use = '1'
					                          and length(me_code) = '2'
					                        order by me_order, me_id ";
					            $result = sql_query($sql, false);
					            $gnb_zindex = 999; // gnb_1dli z-index 값 설정용

					            for ($i=0; $row=sql_fetch_array($result); $i++) {
					            ?>
					            <li class="gnb_1dli" style="z-index:<?php echo $gnb_zindex--; ?>">
					                <a href="<?php echo $row['me_link']; ?>" target="_<?php echo $row['me_target']; ?>" class="gnb_1da"><?php echo $row['me_name'] ?></a>
					                <?php
					                $sql2 = " select *
					                            from {$g5['menu_table']}
					                            where me_use = '1'
					                              and length(me_code) = '4'
					                              and substring(me_code, 1, 2) = '{$row['me_code']}'
					                            order by me_order, me_id ";
					                $result2 = sql_query($sql2);

					                for ($k=0; $row2=sql_fetch_array($result2); $k++) {
					                    if($k == 0)
					                        echo '<ul class="gnb_2dul">'.PHP_EOL;
					                ?>
					                    <li class="gnb_2dli"><a href="<?php echo $row2['me_link']; ?>" target="_<?php echo $row2['me_target']; ?>" class="gnb_2da"><?php echo $row2['me_name'] ?></a>
					                <?php

													//3차메뉴 불러 오기.
													$sql3 = " select *
																from {$g5['menu_table']}
																where me_use = '1'
																  and length(me_code) = '6'
																  and substring(me_code, 1, 4) = '{$row2['me_code']}'
																order by me_order, me_id ";
													$result3 = sql_query($sql3);
													$num3 = sql_num_rows($result3);
													if($num3>0){
														echo '<ul class="gnb_3dul">'.PHP_EOL;
														while($row3=sql_fetch_array($result3)){
												?>
														<li class="gnb_3dli"><a href="<?php echo $row3['me_link']; ?>" target="_<?php echo $row3['me_target']; ?>" class="gnb_3da">- <?php echo $row3['me_name'] ?></a></li>
									<?php
											}
											echo '</ul>'.PHP_EOL;
										}
									echo '</li>';					
					                }
					                if($k > 0)
					                    echo '</ul>'.PHP_EOL;
					                ?>
					            </li>
					            <?php
					            }

					            if ($i == 0) {  ?>
					                <li id="gnb_empty">메뉴 준비 중입니다.<?php if ($is_admin) { ?> <br><a href="<?php echo G5_ADMIN_URL; ?>/menu_list.php">관리자모드 &gt; 환경설정 &gt; 메뉴설정</a>에서 설정하실 수 있습니다.<?php } ?></li>
					            <?php } ?>
					        </ul>
                </div>
                <div id="nav_bar"></div>
            </nav>
            <script>
                $(function() {
                    $(".gnb_menu_btn").click(function() {
                        $("#gnb_all").show();
                    });
                    $(".gnb_close_btn").click(function() {
                        $("#gnb_all").hide();
                    });
                });
            </script>
        </div>
    </div>
</div>
<!-- } 상단 끝 -->
<!--<div class="popup_log">-->
    
<!--</div>-->

<hr>

<!-- 콘텐츠 시작 { -->
<div id="wrapper">
    <div id="container_wr">

        <div id="container">
            <?php if (!defined("_INDEX_")) { ?><h2 id="container_title"><span title="<?php echo get_text($g5['title']); ?>"><?php echo get_head_title($g5['title']); ?></span></h2><?php } ?>