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

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');
?>
<div data-sticky-container id="navigation">
    <div class="title-bar" data-sticky data-sticky-on="small" data-options="marginTop:0;">
        <div class="title-bar-left">
            <div class="mobile-main-menu hide-for-large">
                <button type="button" data-toggle="left-menu-canvas" data-open="left-menu-canvas"><i class="fa fa-2x fa-bars"></i></button>
            </div>
            <div class="ask-logo title-bar-title">
                <a href='/' class='ask-logo-link'>
                    <img src='<?php echo G5_THEME_URL ?>/img/ask-logo.png' width="127" height="27" class='ask-logo-img'>
                </a>
            </div>
            <div class="mobile-main-menu hide-for-large">
                <button type="button" data-toggle="right-menu-canvas" data-open="right-menu-canvas"><i class="fa fa-2x fa-user"></i></button>
            </div>
        </div>
        <div class="title-bar-right show-for-large">
            <div class="main-menu">
                <?php
                $pc_add_item = $mobile_add_item;
                $pc_add_item .= "<li class='ask-parent'><a href='#search' class='ask-parent-link open-search ask-slide-menu' data-status='close' data-target='search-box'><i class='fa fa-search'></i></a></li>";
                $pc_add_item .= "<li class='ask-parent'><a href='#memberbox' class='ask-parent-link open-member ask-slide-menu' data-status='close' data-target='member-box'><i class='fa fa-user'></i></a></li>";
                echo ask_menu($pc_add_item);
                ?>
            </div>
        </div>
        <div class='member-box'>
            <?php
            $member_menu = "<ul>";
            if ($is_admin) {
                $member_menu .= "<li><a href='" . G5_ADMIN_URL . "'><i class='fa fa-cog'></i> 관리자</a></li>";
                $member_menu .= "<li><a href='" . G5_PLUGIN_URL . "/asktheme/_admin/'><i class='fa fa-cogs'></i> 테마관리자</a></li>";
            }
            if ($is_member) {
                $member_menu .= "<li><a href='" . G5_BBS_URL . "/member_confirm.php?url=" . G5_BBS_URL . "/register_form.php'>정보수정</a></li>";
                $member_menu .= "<li><a href='" . G5_BBS_URL . "/logout.php'>로그아웃</a></li>";
                $member_menu .= "";
            } else {
                $member_menu .= "<li><a href='" . G5_BBS_URL . "/register.php'>회원가입</a></li>";
                $member_menu .= "<li><a href='" . G5_BBS_URL . "/login.php'>로그인</a></li>";
            }

            $member_menu .= "<li><a href='" . G5_BBS_URL . "/faq.php'>FAQ</a></li>";
            $member_menu .= "<li><a href='" . G5_BBS_URL . "/qalist.php'>1:1문의</a></li>";
            $member_menu .= "<li><a href='" . G5_BBS_URL . "/current_connect.php'>접속자</a></li>";
            $member_menu .= "<li><a href='" . G5_BBS_URL . "/new.php'>새글</a></li>";
            $member_menu .= "</ul>";
            echo $member_menu;
            ?>
        </div>

        <div class="search-box">
            <form name="fsearchbox" method="get" action="<?php echo G5_BBS_URL ?>/search.php" onsubmit="return fsearchbox_submit(this);">
                <input type="hidden" name="sfl" value="wr_subject||wr_content"/>
                <input type="hidden" name="sop" value="and"/>
                <div class="search-table">
                    <div class="search-field">
                        <input type="text" name="stx" id="sch_stx" class="search-input" maxlength="20" placeholder="검색어를 입력하세요"/>
                    </div>

                    <div class="search-box-btn-field">
                        <button type="submit" class="search-box-btn"><i class='fa fa-2x fa-search'></i></button>
                    </div>
                </div>
            </form>
            <script type="text/javascript">
                function fsearchbox_submit(f) {
                    if (f.stx.value.length < 2) {
                        alert("검색어는 두글자 이상 입력하십시오.");
                        f.stx.select();
                        f.stx.focus();
                        return false;
                    }

                    // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
                    var cnt = 0;
                    for (var i = 0; i < f.stx.value.length; i++) {
                        if (f.stx.value.charAt(i) == ' ') {
                            cnt++;
                        }
                    }

                    if (cnt > 1) {
                        alert("빠른 검색을 위하여 검색어에 공백은 한개만 입력할 수 있습니다.");
                        f.stx.select();
                        f.stx.focus();
                        return false;
                    }

                    return true;
                }
            </script>
        </div>
    </div>
</div>

<div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
    <div class="off-canvas position-left" id="left-menu-canvas" data-off-canvas data-position="left">
        <!-- Close button -->
        <button class="close-button" aria-label="Close menu" type="button" data-close>
            <span aria-hidden="true">&times;</span>
        </button>
        <!--Side Menu -->
        <?php echo ask_mobile_menu($mobile_add_item); ?>
        <!-- //Side Menu-->
    </div>
    <div class="off-canvas position-right" id="right-menu-canvas" data-off-canvas data-position="right">
        <!-- Close button -->
        <button class="close-button" aria-label="Close menu" type="button" data-close>
            <span aria-hidden="true">&times;</span>
        </button>
        <div class="mobile-search-box">
            <form name="fsearchbox" method="get" action="<?php echo G5_BBS_URL ?>/search.php" onsubmit="return fsearchbox_submit(this);">
                <input type="hidden" name="sfl" value="wr_subject||wr_content"/>
                <input type="hidden" name="sop" value="and"/>
                <div class="search-table">
                    <div class="search-field">
                        <input type="text" name="stx" id="sch_stx" class="search-input" maxlength="20" placeholder="검색어를 입력하세요"/>
                    </div>

                    <div class="search-box-btn-field">
                        <button type="submit" class="search-box-btn"><i class='fa fa-2x fa-search'></i></button>
                    </div>
                </div>
            </form>
            <script type="text/javascript">
                function fsearchbox_submit(f) {
                    if (f.stx.value.length < 2) {
                        alert("검색어는 두글자 이상 입력하십시오.");
                        f.stx.select();
                        f.stx.focus();
                        return false;
                    }

                    // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
                    var cnt = 0;
                    for (var i = 0; i < f.stx.value.length; i++) {
                        if (f.stx.value.charAt(i) == ' ') {
                            cnt++;
                        }
                    }

                    if (cnt > 1) {
                        alert("빠른 검색을 위하여 검색어에 공백은 한개만 입력할 수 있습니다.");
                        f.stx.select();
                        f.stx.focus();
                        return false;
                    }

                    return true;
                }
            </script>
        </div>
        <?php echo $member_menu ?>
    </div>
    <div class="off-canvas-content" data-off-canvas-content>
        <?php
        if (defined('_INDEX_')) { // index에서만 실행
            echo plugin_run('모바일메인상단', '[[parallaxcontentslider]]', false, '모바일메인상단');
        } elseif (defined('_GROUP_')) { // index에서만 실행
            echo plugin_run('모바일그룹상단', '[[parallaxcontentslider]]', false, '모바일그룹상단');
        }
        ?>
        <div id="container">
            <div class="row">
                <div id="aside" class="small-12 medium-12 large-3 columns">
                    <div class="row">
                        <div class="small-12 columns">
                            <?php
                            echo outlogin('theme/basic'); // 외부 로그인, 테마의 스킨을 사용하려면 스킨을 theme/basic 과 같이 지정    
                            ?>
                        </div>
                    </div>
                    <?php
                    if (defined('_INDEX_')) { // index에서만 실행 
                        /*
                        echo '<div class="row">';
                        echo '<div class="small-12 columns">';
                        echo poll('theme/basic'); // 설문조사, 테마의 스킨을 사용하려면 스킨을 theme/basic 과 같이 지정
                        echo plugin_run('회원포인트순위', '[[point_chart]]', false, '회원포인트순위'); //메인페이지 사이드에도 회원순위를 출력할 수 있습니다.
                        echo '</div>';
                        echo '</div>';
                         * 
                         */
                    }
                    ?>
                    <?php if ($gr_id) { ?>
                        <?php
                        /*
                         * 사이드메뉴 플러그인
                         * 일반페이지에 사이드 메뉴 추가하기
                         * 페이지 상단에 $gr_id = 'community'; 와 같이 group id 를 입력하세요.
                         * 해당 일반 페이지가 포함되는 그룹의 아이디를 입력하면 됩니다.
                         */
                        echo plugin_run('사이드메뉴', '[[sidemenu]]', false, $gr_id);
                        ?>
                    <?php } ?>
                </div><!--.asde-->

                <div id="contents" class="small-12 medium-12 large-9 columns">