<?php
# session
$SES_MEMBER_ID              = $this->session->userdata('C_Member_Id');
$SES_MEMBER_NAME            = $this->session->userdata('C_Member_Name');
$SES_MEMBER_NICNAME         = $this->session->userdata('C_Member_Nicname');
$SES_MEMBER_PROFILE         = $this->session->userdata('C_Member_Profile');
$SES_MEMBER_GROUPNAME       = $this->session->userdata('C_Member_Group_Name');
$SES_MEMBER_INTRO           = $this->session->userdata('C_Member_Intro');
$SES_MEMBER_EMAIL           = $this->session->userdata('C_Member_Email');

$weekday = array('일','월','화','수','목','금','토');

if($SES_MEMBER_PROFILE == '')   $SES_MEMBER_PROFILE = '/img/web/img_profile_l.png';
if($SES_MEMBER_NICNAME == '')   $SES_MEMBER_NICNAME = $SES_MEMBER_NAME;

$controller = $this->uri->segment(2);
$method = $this->uri->segment(3);
if($controller != 'search') {
    $search_keyword = '';
}
$content_type    = trim($this->input->get_post('content_type', TRUE));


$ci=& get_instance();

# 실시간급상승 검색어
$ci->load->model('web/m_realtime_keyword');
$arr_realtime_keyword    = $ci->m_realtime_keyword->realtime_keyword_all_list();

$return_data['arr_realtime_keyword']        = $arr_realtime_keyword;


?>
<!doctype html>
<!--[if lt IE 7]><html class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="kr"><![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js lt-ie10 lt-ie9 lt-ie8" lang="kr"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie10 lt-ie9" lang="kr"><![endif]-->
<!--[if (IE 9)&!(IEMobile)]><html class="no-js lt-ie10" lang="kr"><![endif]-->
<!--[if gt IE 9]><!--> <html class="no-js" lang="kr"><!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta name="naver-site-verification" content="894ba0807460988349b1e131377b26966e347fc1">
  <meta name="google-site-verification" content="CitaOJM4btglyBtNxZFYymBBzh3g7Pb9PxKl9YF8jDg">
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
  <!-- <meta http-equiv="cleartype" content="on"> -->
  <title>크로스맵 - 기독교 종합 포털</title>
  <meta name="description" content="크로스맵은 일상 속에서 은혜를 구하는 크리스천을 위한 기독교 종합 포털사이트입니다.">
  <meta name="keywords" content="교계뉴스,라이프,3분말씀,말씀엽서,운율이 있는 묵상,QT">
  <meta name="author" content="">
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  <meta property="fb:app_id" content="961578337335000">

  <!-- favicons -->
  <link rel="shortcut icon" href="/img/shortcut_icon.png">
  <link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon">
  <link rel="apple-touch-icon" href="/img/shortcut_icon.png">
  <link rel="apple-touch-startup-image" href="/img/shortcut_icon.png">
  
  <!-- css -->
  <link rel="stylesheet" href="/renew/css/main.css">

  <!-- js -->
  <script src="/js/jquery-3.3.1.min.js"></script>
  <script src="/js/web/common.js?1546187583"></script>
  <script src="/js/web/jquery.vticker.min.js"></script>
  <script src="//developers.kakao.com/sdk/js/kakao.min.js"></script>
  <script type="text/javascript" src="/smarteditor/js/HuskyEZCreator.js" charset="utf-8"></script>

  <!-- Font -->
  <link href="https://fonts.googleapis.com/css?family=Nanum+Gothic" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Nanum+Myeongjo" rel="stylesheet"> 
 <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
  <!-- javascript -->
  <!--[if (lt IE 9)]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <script src="assets/js/ie.min.js"></script>
    
    <link href="http://externalcdn.com/respond-proxy.html" id="respond-proxy" rel="respond-proxy" />
    <link href="assets/cross-domain/respond.proxy.gif" id="respond-redirect" rel="respond-redirect" />
    <script src="assets/cross-domain/respond.proxy.js"></script>  
  <![endif]-->
  <script src="/renew/js/script.js"></script>
</head>
<body>
<noscript>
  <p class="enable-js">
    To enjoy our website, you'll need to enable <b>JavaScript</b> in your web browser. Please <a href="http://enable-javascript.com/" target="_blank"><b>click here</b></a> to learn how.
  </p>
</noscript>
<!--[if lt IE 8]>
  <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/" target="_blank">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

 
   
<header class="site-head">
  <div class="container">
   <label for="nav-toggle" class="nav-toggle"><i class="fa fa-bars"></i>
   </label>
   <div class="util">
     <a href="javascript:bookmark_site('<?=$site_info['homepage_title']?>', 'http://crossmap.co.kr')">즐겨찾기</a>
     <a href="/web/cs/faq_view/33?search_keyword=&search_category1=31&search_category2=02&data_num=2">시작페이지로</a>
   </div>
    <div class="logo"><a href="/"><img src="/renew/img/logo-b.gif" alt="크로스맵"></a></div>
    <div class="social">
      <a href="mailto:service@crossmap.co.kr"><img src="/renew/img/ic-email.gif" alt="Email"></a>
      <a href="https://www.facebook.com/crossmapkr/" target="_blank"><img src="/renew/img/ic-fb.gif" alt="Facebook"></a>
      <a href="https://www.instagram.com/crossmapkr/" target="_blank"><img src="/renew/img/ic-insta.gif" alt="Instagram"></a>
    </div>
  </div>
    <!--Desktop Nav-->
  <div class="site-nav-desktop">
    <div class="container">
      <nav>
        <ul>
          <li><a href="/"><img src="/renew/img/ic-home.gif" alt="home"></a></li>
          <li><a href="/web/life/">라이프</a></li>
          <li><a href="/web/news/">뉴스</a></li>
        </ul>
      </nav>
<?php
if($is_mobile==false) {
?>      
      <div class="keyword" onclick="change_toggle('realtime_rank');return false;" id="roll_realtime_keyword" style="float: right;width: 155px;padding-left:20px;">
        <ul>
          <?
foreach ($arr_realtime_keyword as $key=>$val) {

    //if($key == 10) echo '<ul class="roll_box" id="realtime_keyword_list2" style="display:none">';

    $last_rank  = $val['last_rank'];
    $rank       = $val['rank'];

    $class = '';
    $last_rank_txt = '';
    if($last_rank==0){
        $class = 'new';
        $last_rank_txt = 'NEW';
    } else {
        $calc_rank = $last_rank - $rank;
        if($calc_rank == 0){   // 같음
            $last_rank_txt = '-';
        } else if($calc_rank > 0){   // up
            $last_rank_txt = '<img src="/img/web/btn_up.jpg">'.$calc_rank;
        } else {
            $last_rank_txt = '<img src="/img/web/btn_down.jpg">'.abs($calc_rank);
        }
    }

    $keyword = mb_strimwidth($val['keyword'], '0', '25', '..', 'utf-8');
          ?>
          <li>
            <span><?php echo $rank;?></span> 
            <a href="/web/search/?search_keyword=<?=urlencode($val['keyword'])?>"><?php echo $keyword;?></a>
          </li>
<?php }?>    
        </ul>
      </div>
<?php
}?>
      <!--Keyword Box Over-->
      <div class="keywordOver" id="realtime_rank" style="display:none;">
        <ul>
          <li><i class="fas fa-arrow-up"></i> 실시간 급상승</li>
<?
foreach ($arr_realtime_keyword as $key=>$val) {
$last_rank  = $val['last_rank'];
$rank       = $val['rank'];

$class = '';
$last_rank_txt = '';
if($last_rank==0){
    $class = 'new';
    $last_rank_txt = 'NEW';
} else {
    $calc_rank = $last_rank - $rank;
    if($calc_rank == 0){   // 같음
        $last_rank_txt = '-';
    } else if($calc_rank > 0){   // up
        $last_rank_txt = '<img src="/img/web/btn_up.jpg">'.$calc_rank;
    } else {
        $last_rank_txt = '<img src="/img/web/btn_down.jpg">'.abs($calc_rank);
    }
}

$keyword = mb_strimwidth($val['keyword'], '0', '25', '..', 'utf-8');
?>
          <li>
            <span><?php echo $rank;?></span> 
            <a href="/web/search/?search_keyword=<?=urlencode($val['keyword'])?>"><?php echo $keyword;?></a>
          </li>
<?php }?>          
        </ul>
      </div>
      
      <!--Mobile top-->
      <div class="search">
        <form name="search_form" id="search_form" method="get" action="/web/search/" onsubmit="return submit_check(); return false;">
          <input type="text" id="search_keyword" name="search_keyword"  placeholder="검색어를 입력하세요">
          <button type="submit" id="search_btn"><i class="fa fa-search"></i></button>
        </form>
      </div>
    </div>
  </div>
  <div class="site-head-nav">
    <div class="container">
      <input type="checkbox" name="" class="" id="nav-toggle">
      <div class="nav-wrap">
        <label for="nav-toggle" class="nav-toggle"><i class="fas fa-times"></i></i>
        </label>
        <nav class="site-nav">
          <ul>
            <li><a href="/">홈</a></li>
            <li><a href="/web/life/">라이프</a></li>
            <li><a href="/web/news/">뉴스</a></li>
            <li class="login"><a href="/web/user/login">로그인</a></li>
          </ul>
        </nav>
      </div>
    </div>
  </div>
 
</header>

<div class="container">
  <div class="leftCon">
    <div class="banner"><a href="http://www.cplace.co.kr/" target="_new"><img src="/renew/img/banner-1.gif"></a></div>
<?php
$now_date = date("m.d");
$week_date = date('w');
$weather_date_txt = $now_date.'('.$weekday[$week_date].')';
?>

    <div class="prayerRQ">
      <strong>세계기도제목</strong> 
      <span class="blue"><?php echo $weather_date_txt?></span>
      <!--<span class="blue">인도</span> -->
      <div id="cross_weather">
      <ul class="prayer">
<?php
foreach ($arr_weather as $val) {
$title = (isset($val['title'])==TRUE) ? mb_substr($val['title'], '0', '40', 'utf-8') : '';
?> 
        <li><a href="/web/news/news_view/<?=$val['relation_article_idx']?>"><?=$title?></a></li>
<?php
}?>
      </ul>
      </div>
      <div class="more"><a href="#">관련 기사 더보기</a></div>
    </div>

    <div class="newsBox">
<?php
if(isset($arr_headline_news[1])==true) {
  $title      = mb_strimwidth($arr_headline_news[1]['title'], '0', '38', '..', 'utf-8');
  //$sub_content  = mb_strimwidth($arr_headline_news[1]['sub_content'], '0', '110', '..', 'utf-8');
?>      
      <div class="photoNews">
        <a href="/web/news/news_view/<?php echo $arr_headline_news[1]['content_idx']?>">
          <img src="<?php echo $arr_headline_news[1]['theme_img']?>" width="380" height="263" border="0" />
        </a>
        <h2>
          <a href="/web/news/news_view/<?php echo $arr_headline_news[1]['content_idx']?>"><?php echo $title?></a>
        </h2>
      </div>
<?php
}
?>      
      <ul>
<?php
for($i=2;$i<10;$i++) {
  if(isset($arr_headline_news[$i])==true) {
    $title = $arr_headline_news[$i]['title'];
?>        
        <li><a href="/web/news/news_view/<?php echo $arr_headline_news[$i]['content_idx'];?>"><?php echo $title;?></a></li>
<?php 
  }
}?>
      </ul>
    </div>

    <div class="logoBox">
      <ul class="titleBox">
        <li class="current"><a href="#">방송사</a></li>
        <li><a href="#" onclick="alert('준비중입니다.'); return false;">신문사</a></li>
        <li><a href="#" onclick="alert('준비중입니다.'); return false;">페이스북</a></li>
        <li><a href="#" onclick="alert('준비중입니다.'); return false;">인스타그램</a></li>
        <li><a href="#" onclick="alert('준비중입니다.'); return false;">기타</a></li>
      </ul>

      <ul class="logoList">
<?php
$i=1;
foreach($arr_press as $val) {
?>        
        <li><a href="<?=$val['homepage']?>"><img src="<?=$val['logo_img']?>" alt="" height="24"></a></li>
<?php }?>
      </ul>
    </div>
<style>
#today_column li {/*width:500px;*/ padding-left:10px;}
</style>
    <div class="todayColumn">
      <div class="column">오늘의 칼럼</div>
      <div class="columnTitleBox" id="columnTitleBox">
        <?
        if(count($arr_today_column) > 0 ) {
          //echo '<div class="columnTitle" id="today_column" style=""><ul style="overflow:hidden;height:18px;margin-top:10px;">'; 
          //20190213 vtical 오류수정중 columnTitl제거
          echo "<ul>";
          foreach ($arr_today_column as $val) {
            $title = '['.$val['column_name'].'] '.$val['title'];
            $title = mb_strimwidth($title, '0', '90', '..', 'utf-8');
        ?>
              <li><a href="/web/news/column_view/<?=$val['content_idx']?>"><?=$title?></a></li>
        <?php 
          }
          echo '</ul>';
        }?>
      </div>
      <a class="more" href="/web/news/column">더보기</a>
    </div>

    <!-- 모아보기 -->
    <?php include_once(APPPATH."views/web/homepage/column1.php"); ?>
    <!-- //모아보기 -->

    <!-- Crossmap TV -->
    <?php include_once(APPPATH."views/web/homepage/column2.php"); ?>
    <!-- //Crossmap TV -->

    <!-- 이런건 어때? -->
    <?php include_once(APPPATH."views/web/homepage/column3.php"); ?>
    <!-- //이런건 어때? -->

  </div>
  <!--Sidebar start-->  
  <div class="sideBar">
<?php
if($SES_MEMBER_ID=='') {
?>
    <div class="loginBox">
        <fieldset>
          <div class="inputBox">
            <input type="text" name="main_login_member_id" id="main_login_member_id" placeholder="아이디">
            <input type="password" name="main_login_member_pwd" id="main_login_member_pwd" placeholder="비밀번호" onkeypress="if( event.keyCode==13 ){main_login_proc();}">
          </div>
          <div class="loginBt">
            <input type="button" title="로그인" value="로그인" onclick="main_login_proc();">
          </div>
        </fieldset>
        <div class="checkLogin">
          <input type="checkbox">
          <label>로그인 상태 유지</label>
          <!--a class="signup" href="#" onclick="show_popup('user_popup');return false;">회원가입</a>
          <a href="#" onclick="show_popup('id_popup');return false;">아이디</a>
          <a class="dot" href="#" onclick="show_popup('password_popup');return false;">비밀번호 찾기</a-->
          <a class="signup" href="/web/user/register">회원가입</a>
          <a href="/web/user/find_id">아이디</a>
          <a class="dot" href="/web/user/find_password">비밀번호 찾기</a>
        </div>
    </div>
<?php
} else {
?>
    <!-- login -->
    <div >
      <div class="mypage_opened_box">
        <div class="mypage_opened_info2">
          <div class="profile2">
            <span class="profile_l"><a href="javascript:commonLayerOpen('passwd_check_layer')"><img src="" width="47"><?=$SES_MEMBER_NICNAME?></a></span>
            <span class="carmera"><img src="/img/web/img_camera.png"></span>
          </div>
          <div class="profile_detail" >
            <span class="name"><a href="javascript:commonLayerOpen('passwd_check_layer');"><?=$SES_MEMBER_NICNAME?></a></span> 님
            <div style="padding-top:7px; color:#000" ><span class="beachblue beauchblue_underline"><a href="javascript:commonLayerOpen('passwd_check_layer')">내정보</a></span><span class="grey"></span> <?=$SES_MEMBER_GROUPNAME?></div>
          </div>
          <div class="logout">
            <span class="btn"><a href="/web/member/logout_proc">로그아웃</a></span>
          </div>
        </div>
        <ul class="mypage_menu2">
         <li><a href="/web/cs/notice">알림</a></li>
         <li><a href="javascript:change_toggle('delivery_layer')">배달함 </a></li>
         <li><a href="javascript:user_comment('<?php echo $SES_MEMBER_ID?>');">내댓글</a></li>
         <li> <a href="/web/mypage/bookmark">북마크</a></li>
         <!--li> <a href="/m/" target="_blank">모바일 보기</a></li-->
        </ul>
      </div>
    </div>
    <!-- //login -->
<?php }?>
    <div class="dailyWord">
      <div class="title">
        <span><?php echo date("m.d")?>(<?php echo $weekday[date("w")]?>)</span>
        <img src="/renew/img/ic-daily.gif">
        <span class="blue">오늘의 말씀</span>
      </div>
      <div class="word">
        <?php echo $arr_today_word['word']?>
      </div>
      <span class="verse"><?php echo $arr_today_word['title']?></span>
    </div>
<?php
if(count($arr_daily_cutie) > 0) {
?>
    <div class="dailyQT">
      <a href="/web/life/life_view/<?php echo $arr_daily_cutie[1]['content_idx']?>" target="_new"><div class="photo" style="background:url('<?php echo $arr_daily_cutie[1]['theme_img'];?>') no-repeat center; background-size:cover;"></div></a>
      <p class="qttitle">데<span>일리큐</span>티</p>
      <p class="qttxt"><a href="/web/life/life_view/<?php echo $arr_daily_cutie[1]['content_idx']?>"><?php echo $arr_daily_cutie[1]['title']?></a></p>
    </div>
<?php }?>
    <div class="banner300">
      <a href="http://www.cplace.co.kr/" target="_new"><img src="/renew/img/banner-2.gif?id=<?php echo mt_rand(1,100);?>"></a>
    </div>
    
    <div class="musicChart">
      <div class="mcTitle">
        <span>음원차트</span>
        <a href="https://www.melon.com/chart/day/index.htm?classCd=GN2100" target="_new" class="more">더보기</a>
      </div>
      <ul>
<?php
foreach($arr_melon_ccm as $k=>$v) {
  if(isset($v[0])==TRUE && isset($v[1])==TRUE && isset($v[2])==TRUE) {
?>
        <li>
          <div class="number"><?php echo $k+1;?></div>
          <div class="thumbImg"><img src="<?php echo $v[0];?>" alt="<?php echo addslashes($v[1])?>" ></div>
          <div class="songTxt">
            <div class="song"><a href="https://www.youtube.com/results?search_query=<?php echo urlencode($v[1].' '.$v[2])?>" target="_new"><?php echo addslashes($v[1])?></a></div>
            <div><a><?php echo addslashes($v[2])?></a></div>
          </div>
        </li>
<?php
  }
}
?>
      </ul>
    </div>

    <div class="banner300">
      <a href="http://www.cplace.co.kr/" target="_new"><img src="/renew/img/banner-2.gif?id=<?php echo mt_rand(1,100);?>"></a>
    </div>

  </div>
</div>
<!-- container end -->

<!--footer start-->
<div class="footer">
  <div class="container">
   <div class="ftLogo"><a href="/"><img src="/renew/img/logo-b.gif" alt="크로스맵"></a></div>
   <ul>
      <li><a href="https://hwttjung.wixsite.com/mysite-1" target="https://hwttjung.wixsite.com/mysite-1">회사소개</a></li>
      <li><a href="/web/rules/privacy">개인정보 취급방침</a></li>
      <li><a href="/web/rules/service">이용약관</a></li>
      <li><a href="/web/cs/notice">고객센터</a></li>
      <li><a href="https://www.facebook.com/crossmapkr/" target="_new"><i class="fab fa-facebook-f"></i>페이스북</a></li>
      <li><a href="https://www.instagram.com/crossmapkr/" target="_new"><i class="fab fa-instagram"></i>인스타그램</a></li>
   </ul>
  </div>
</div>
<!--footer end-->

<? /*
<!--2019.02.20 팝업 주석처리 -->
<div id="user_popup" style="display:none;position:fixed;top:50px;left:30%;width:700px;height:90%;">
  <div style="float:right;cursor:pointer;" onclick="hide_popup('user_popup')">Close</div>
  <div style="width:100%;height: 100%;">
  <iframe src="/web/popup" width="700" height="700" frameborder="0" scrolling="yes"></iframe>
  </div>
</div>

<div id="id_popup" style="display:none;position:fixed;top:50px;left:30%;width:700px;height:90%;">
  <div style="float:right;cursor:pointer;" onclick="hide_popup('id_popup')">Close</div>
  <div style="width:100%;height: 100%;">
  <iframe src="/web/popup/find_id" width="700" height="700" frameborder="0" scrolling="yes"></iframe>
  </div>
</div>

<div id="password_popup" style="display:none;position:fixed;top:50px;left:30%;width:700px;height:90%;">
  <div style="float:right;cursor:pointer;" onclick="hide_popup('password_popup')">Close</div>
  <div style="width:100%;height: 100%;">
  <iframe src="/web/popup/find_password" width="700" height="700" frameborder="0" scrolling="yes"></iframe>
  </div>
</div>
<!-- -->
*/ ?>

<iframe id="kmc_mobile_auth" src="/web/comm/kmc_mobile_auth" style="width:300px;height:300px;position:absolute; top:0; left:0px;z-index: -10" ></iframe>
</body>
<script type="text/javascript">


var user_comment_page = 1;
var user_comment_content_type = '3';
var user_comment_write_id = 'hwttjung';
var user_comment_sort = '2';



$(".mask").on('click', function(event){
    $(event.target).parent().hide();

});

$('.user_replay_text').click(function(e) {
  $("#social_login").toggle();

    $(".popup_wrap").css('left','50%');
  $(".popup_wrap").css('top',popH+'px');

});

$('.user_comment_text').on('keyup', function(event) {
  var key = $(this).attr('strA');
  var len = $(this).val().length;
    if (len >= 300) {
        $(this).val($(this).val().substring(0, 300));
    len = 300;
    }
    $("#user_reply_text_count"+key).html(len+'/300');
});





// sort
function change_user_comment_sort(type){
  user_comment_sort = type;
  user_comment_page = 1;
  user_comment_list();

  $('#user_comment_sort1').toggleClass('current');
    $('#user_comment_sort2').toggleClass('current');
    $('#user_comment_sort3').toggleClass('current');
    $('#user_comment_sort4').toggleClass('current');
}


// content_type
function change_user_comment_content_type(type){
  user_comment_content_type = type;
  user_comment_page = 1;
  user_comment_list();

  $('#user_comment_menu1').removeClass('current');
    $('#user_comment_menu2').removeClass('current');
    $('#user_comment_menu3').removeClass('current');

    $('#user_comment_menu'+type).addClass('current');



}


function user_comment_list() {

  var form_data = {
    "page"          : user_comment_page,
    "content_type"  : user_comment_content_type,
    "write_id"    : user_comment_write_id,
    "sort"      : user_comment_sort
  };
  $.ajax({
        url: '/web/comm/user_comment_list',
        async: false,
        type: 'POST',
        dataType: 'HTML',
        data: form_data,
        success: function (rtnHtml) {
          if(rtnHtml=='') return false;
      var arrHtml = rtnHtml.split("|||||");
      if(arrHtml[0].trim()=='0000') {
          if(user_comment_page == 1) {
              $("#user_comment_list").html(arrHtml[1]);
                } else {
                    $("#user_comment_list").append(arrHtml[1]);
                }
                var total_count = setComma(arrHtml[2]);
                $("#user_comment_count").html(total_count);

        if (arrHtml[3] == "N") {
          $("#user_comment_more_btn").hide();
          $("#user_comment_bottom").show();
        } else {
          $("#user_comment_more_btn").show();
          $("#user_comment_bottom").hide();
        }
        user_comment_page++;

      } else {
        alert(arrHtml[1]);
                return false;
      }
        },
        error: function (rtnHtml) {
            alert('데이터 가져오기에 실패했습니다.');
            return false;
        }
    });
}

// 대댓글 더보기
function user_comment_reply_more(idx){
  var page = $("#user_comment_reply_page"+idx).val();
  page = parseInt(page) + 1;
  $("#user_comment_reply_page"+idx).val(page);
  user_comment_reply_list(idx, page);

}


var user_comment_reply_open_type = 1;
function user_comment_reply_open(idx){

  if(user_comment_reply_open_type ==1) {
        $("#user_comment_reply_box"+idx).css("display","block");
    user_comment_reply_list(idx, 1);

        user_comment_reply_open_type = 2;
    } else {
        $("#user_comment_reply_box"+idx).css("display","none");
        user_comment_reply_open_type = 1;
    }


}


function user_comment_reply_list(idx, page) {
  var form_data = {
    "page"        : page,
    "sort"        : user_comment_sort,
    "comment_idx" : idx,
    "type"      : "user_comment"
  };
  $.ajax({
        url: '/web/comm/comment_reply_list',
        async: false,
        type: 'POST',
        dataType: 'HTML',
        data: form_data,
        success: function (rtnHtml) {
          if(rtnHtml=='') return false;
      var arrHtml = rtnHtml.split("|||||");
      if(arrHtml[0].trim()=='0000') {
          if(page == 1) {
              $("#user_comment_reply_list"+idx).html(arrHtml[1]);
                } else {
                    $("#user_comment_reply_list"+idx).append(arrHtml[1]);
                }
                var total_count = setComma(arrHtml[2]);
                $("#user_comment_reply_count").html(total_count);
        console.log(arrHtml[3]);
        if (arrHtml[3] == "N") {
          $("#user_comment_reply_more_btn"+idx).hide();
        } else {
          $("#user_comment_reply_more_btn"+idx).show();
        }
      } else {
        alert(arrHtml[1]);
                return false;
      }
        },
        error: function (rtnHtml) {
            alert('데이터 가져오기에 실패했습니다.');
            return false;
        }
    });
  $("#user_comment_reply_box"+idx).show();



}




// 대대글 달기
function user_comment_reply_add_proc(p_idx, content_idx){
  if("hwttjung"=="") {
    alert("로그인 후에 이용가능합니다.");
    return;
  }

  if($("#user_comment"+p_idx).val()=="") {
    alert("댓글을 입력해주세요.");
    return;
  }

  var form_data = {
    "p_idx"         : p_idx,
    "content_idx"     : content_idx,
    "content_type"      : user_comment_content_type,
    "comment"       : $("#user_comment"+p_idx).val()
  };
  $.ajax({
        url: '/web/comm/comment_add_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
    success: function (rtnJson) {
          if (rtnJson.code == "0000") {
        $("#user_comment"+p_idx).val('');
        $("#user_reply_text_count"+p_idx).html('0/300');
        $("#user_comment_reply_page"+p_idx).val(1);

        user_comment_reply_list(p_idx, 1);
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('저장에 실패했습니다.');
            return false;
        }
    });
}

function user_comment_del(idx){
  if(confirm("댓글이 삭제됩니다. 삭제하시겠습니까?") == false) {
    return false;
  }

    var form_data = {
        "idx"     : idx
    };
    $.ajax({
        url: '/web/comm/user_comment_del_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
              user_comment_page = 1;
                user_comment_list();

            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('삭제에 실패했습니다.');
            return false;
        }
    });
}

function user_reply_comment_del(idx, p_idx){
  if(confirm("댓글이 삭제됩니다. 삭제하시겠습니까?") == false) {
    return false;
  }

    var form_data = {
        "idx"     : idx
    };
    $.ajax({
        url: '/web/comm/user_comment_del_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
              user_comment_reply_list(p_idx, 1);
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('삭제에 실패했습니다.');
            return false;
        }
    });
}

function user_comment(write_id, write_name){
  user_comment_page = 1;
  user_comment_write_id = write_id;
  user_comment_list();
  $("#user_comment_layer").show();
  $("html, body").scrollTop(0);
  if(write_name!='') {
    $("#user_comment_nicname").html(write_name);
  }
}

function copy_user_comment_url(idx){
    $('#copy_user_comment_url'+idx).select();
    try {
        document.execCommand('copy');
        alert("주소가 복사되었습니다.")
    } catch (err) {
        alert('이 브라우저는 지원하지 않습니다.')
    }
}

// 댓글 좋아요
function user_comment_like_select(type, idx){
  if("hwttjung"=="") {
        alert("로그인 후에 이용가능합니다.");
        return;
    }
  var form_data = {
    "comment_idx"     : idx,
    "type"          : type
  };
  $.ajax({
        url: '/web/comm/comment_like_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
              var like_count  = setComma(rtnJson.data.like_count);
              var bad_count   = setComma(rtnJson.data.bad_count);
        $("#comment_like1_"+idx).html(like_count);
        $("#comment_like2_"+idx).html(bad_count);

            } else {
                alert("저장에 실패했습니다.");
                return false;
            }
        },
        error: function (rtnJson) {
            alert('저장에 실패했습니다.');
            return false;
        }
    });
}

function logout_advice(){
  alert("로그아웃 후에 이용해주세요.");
  return false;
}


$(function() {
  $(document).ready(function() {
    $('#roll_realtime_keyword').show();
    $('#roll_realtime_keyword').vTicker();
  });

  $( document ).ready(function() {
    $("#cross_weather").show();
    $('#cross_weather').vTicker();
    $("#cross_weather").css('height','20px');
  });

  $( document ).ready(function() {
    $("#columnTitleBox").show();
    $('#columnTitleBox').vTicker('init',{showItems: 1});
    // $("#today_column").css({"overflow":"unset"});
  });
});

function show_popup(id) {
  if($("#"+id)) {
    $("#"+id).show();
  }
}

function hide_popup(id) {
  if($("#"+id)) {
    $("#"+id).hide();
  }
}

// column conversion
var column_1 = 0;
var column_2 = 0;
var column_3 = 0;
// var num_of_column3 = 3;
function column_tab_conversion(class_name,action,column_number) {
  cnt = 0;
  if(action=='next') {
    console.log('------- next -------');
    if(column_number==1) {
      column_1++;
      cnt = column_1%5;
      if(cnt==0)
        column_1 = 0;
    }
    else if(column_number==2) {
      column_2++;
      cnt = column_2%4;
      if(cnt==0)
        column_2 = 0;
    }
    else if(column_number==3) {
      column_3++;
      cnt = column_3%3;
      if(cnt==0)
        column_3 = 0;
    }
  }
  else {
    console.log('------- prev -------');
    if(column_number==1) {
      column_1--;
      if(Math.abs(column_1)%5==0)
        cnt = 0;
      else
        cnt = 5-Math.abs(column_1%5);
      if(cnt==0)
        column_1 = 0;
    }
    else if(column_number==2) {
      column_2--;
      cnt = 4+column_2%4;
      if(Math.abs(column_2)%4==0)
        cnt = 0;
      else
        cnt = 4-Math.abs(column_2%4);
      if(cnt==0)
        column_2 = 0;
    }
    else if(column_number==3) {
      column_3--;
      cnt = 3+column_3%3;
      if(Math.abs(column_3)%3==0)
        cnt = 0;
      else
        cnt = 3-Math.abs(column_3%3);
      if(cnt==0)
        column_3 = 0;
    }
  }
  
  if(class_name!='' && action!='') {
    $("."+class_name).hide();
    column_id = class_name+cnt;
    console.log("show : "+"#"+column_id);
    $("#"+column_id).show();

    if(column_number==1 || column_number==3) {
      $("#"+class_name+"_four_"+cnt).show();
    }
    $("."+class_name+"_menu").attr('class',class_name+'_menu');
    $("#"+class_name+"_menu"+cnt).attr('class','current '+class_name+'_menu');
  }
  return false;
}

function set_column_tab(obj,id_num,class_name,column_number) {
  if(id_num>=0 && class_name!='' && column_number>=0) {
    $("."+class_name).hide();
    $("#"+class_name+id_num).show();
    if(column_number==1 || column_number==3) {
      $("#"+class_name+"_four_"+id_num).show();
      $("#"+class_name+" > li").removeClass('current');
      $(obj).addClass('current');
    } else {
      $("."+class_name+'_menu').removeClass('current');
      $(obj).addClass('current');
    }

    if(column_number==1) {
      column_1 = id_num;
    }
    else if(column_number==2) {
      column_2 = id_num;
    }
    else if(column_number==3) {
      column_3 = id_num;
    }
  }
  return false;
}

// 레이어 이외의 공간 클릭시 close
$(document).mouseup(function (e){
    var container = $("#mybox");
    if( container.has(e.target).length === 0)   container.hide();

    var container = $("#realtime_rank");
    if( container.has(e.target).length === 0)   container.hide();

    var container = $("#search_keyword_box");
    if( container.has(e.target).length === 0){
        container.hide();
        $("#search_arrow").removeClass();
        $("#search_arrow").addClass('src_icon arrow_down_on');
    }
});

$(".mask").on('click', function(event){
    $(event.target).parent().hide();

});


// 실시간급상승
function change_realtime_rank(page){
    $("#realtime_keyword_list1").hide();
    $("#realtime_keyword_list2").hide();
    $("#realtime_keyword_list"+page).show();


    $("#realtime_btn1").removeClass();
    $("#realtime_btn2").removeClass();
    $("#realtime_btn"+page).addClass('current');

}


// 검색
function onkeyup_search_keyword(val){
    if(val == '') {            
        $("#search_arrow").removeClass();
        $("#search_keyword_list").empty();
        $("#search_keyword_box").hide();
        $("#search_arrow").addClass('src_icon arrow_down_on');
    } else {
        var form_data = {
            "keyword" : val
        };
        $.ajax({
            url: '/web/search/search_keyword',
            type: 'POST',
            dataType: 'JSON',
            data: form_data,
            success: function (rtnJson) {
                if (rtnJson.code == "0000") {
                    var count = rtnJson.data.length;
                    var content = '';
                    for(var i=0;i<count;i++) {
                        var result = rtnJson.data[i];
                        var result_keyword = result.keyword;
                        keyword = result_keyword.replace(val, '<span class="on">'+val+'</span>')
                        content+= ' <div><span><a href="javascript:search_keyword_proc(\''+result_keyword+'\');">'+keyword+'</a></span><span class="close fr"></span><span class="date fr"></span></div>';
                    }
                    $("#search_keyword_list").html(content);
                    $("#search_arrow").removeClass();
                    $("#search_keyword_box").show();
                    $("#search_arrow").addClass('src_icon arrow_up_on');
                } else {
                    $("#search_arrow").removeClass();
                    $("#search_keyword_list").empty();
                    $("#search_keyword_box").hide();
                    $("#search_arrow").addClass('src_icon arrow_down_on');
                }
            },
            error: function (rtnJson) {
            }
        });
    }
}

function submit_check() {
    if(!$("#search_keyword").val()) {
        alert('검색어를 입력하세요.');
        return false;
    } else {
        return true;
    }
}

function search_keyword_proc(search_keyword){
    if(search_keyword == '') {
        search_keyword = $("#search_keyword").val();
    }
    
    var result = true;
    if(search_keyword!='')  result = search_keyword_reg(search_keyword);
    if(result==true) {
        $("#search_keyword").val(search_keyword);
        $("#search_form").submit();
    }

}


// 즐겨찾기
function bookmark_site(title,url) {
    if(window.chrome){  // Google Chrome
      alert("Ctrl+D키를 누르시면 즐겨찾기에 추가하실 수 있습니다.");
   } else if (window.sidebar) { // firefox
       window.sidebar.addPanel(title, url, "");
   } else if(window.opera && window.print) { // opera
      var elem = document.createElement('a');
      elem.setAttribute('href',url);
      elem.setAttribute('title',title);
      elem.setAttribute('rel','sidebar');
      elem.click();
   } else if(window.external) {   // Internet Explorer
        window.external.AddFavorite(url, title);
    }
}

// 로그인
function main_login_proc(){
    if($("#main_login_member_id").val()=="") {
        alert("아이디를 입력해주세요.");
        return false;
    }
    if($("#main_login_member_pwd").val()=="") {
        alert("아이디를 입력해주세요.");
        return false;
    }

  var save_login = 'N';
  if($('input:checkbox[id="main_save_login"]').is(":checked") == true){
    save_login = $('input:checkbox[id="main_save_login"]').val()
  }

    var form_data = {
        "member_id"   : $("#main_login_member_id").val(),
        "member_pwd"    : $("#main_login_member_pwd").val(),
        "save_login"    : save_login
    };
    $.ajax({
        url: '/web/member/login_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
              if(rtnJson.msg!=''){
                    alert(rtnJson.msg);
                }
                location.href="/";
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('로그인에 실패했습니다.');
            return false;
        }
    });
}



// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
    if (response.status === 'connected') {
        FB.api('/me', function(response) {
            if(response.id!='') {
                var form_data = {
                    "id"          : response.id,
                    "name"          : response.name
                };
                $.ajax({
                    url: '/web/share/facebook_login_proc',
                    async: false,
                    type: 'POST',
                    dataType: 'JSON',
                    data: form_data,
                    success: function (rtnJson) {
                        if (rtnJson.code == "0000") {
                            window.location.reload();
                        } else {
                            alert("페이스북 로그인에 실패했습니다.");
                            return false;
                        }

                    },
                    error: function (rtnJson) {
                        return false;
                    }
                });
            }


        });
    }
}

function checkLoginState() {
    window.FB.login(function(response) {
        console.log(response);
        if (response.status === 'connected') {
            statusChangeCallback(response);
        }
    });
}


window.fbAsyncInit = function() {
    FB.init({
        appId      : '961578337335000',
        cookie     : true,  // enable cookies to allow the server to access
        xfbml      : true,  // parse social plugins on this page
        version    : 'v2.8' // use graph api version 2.8
    });
};
// Load the SDK asynchronously
(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<!-- Default Statcounter code for Crossmap.co.kr
http://crossmap.co.kr -->
<script type="text/javascript">
var sc_project=10767957; 
var sc_invisible=1; 
var sc_security="0cf2c0fe"; 
</script>
<script type="text/javascript"
src="https://www.statcounter.com/counter/counter.js"
async></script>
<noscript><div class="statcounter"><a title="Web Analytics"
href="https://statcounter.com/" target="_blank"><img
class="statcounter"
src="//c.statcounter.com/10767957/0/0cf2c0fe/1/" alt="Web
Analytics"></a></div></noscript>
<!-- End of Statcounter Code -->

<script language='javascript'>
  var _AceGID=(function(){var Inf=['gtp13.acecounter.com','8080','AH5A41707571392','AW','0','NaPm,Ncisy','ALL','0']; var _CI=(!_AceGID)?[]:_AceGID.val;var _N=0;var _T=new Image(0,0);if(_CI.join('.').indexOf(Inf[3])<0){ _T.src =( location.protocol=="https:"?"https://"+Inf[0]:"http://"+Inf[0]+":"+Inf[1]) +'/?cookie'; _CI.push(Inf);  _N=_CI.length; } return {o: _N,val:_CI}; })();
  var _AceCounter=(function(){var G=_AceGID;var _sc=document.createElement('script');var _sm=document.getElementsByTagName('script')[0];if(G.o!=0){var _A=G.val[G.o-1];var _G=(_A[0]).substr(0,_A[0].indexOf('.'));var _C=(_A[7]!='0')?(_A[2]):_A[3];var _U=(_A[5]).replace(/\,/g,'_');_sc.src=(location.protocol.indexOf('http')==0?location.protocol:'http:')+'//cr.acecounter.com/Web/AceCounter_'+_C+'.js?gc='+_A[2]+'&py='+_A[4]+'&gd='+_G+'&gp='+_A[1]+'&up='+_U+'&rd='+(new Date().getTime());_sm.parentNode.insertBefore(_sc,_sm);return _sc.src;}})();
</script>
<noscript><img src='http://gtp13.acecounter.com:8080/?uid=AH5A41707571392&je=n&' border='0' width='0' height='0' alt=''></noscript> 
<!-- AceCounter Log Gathering Script End -->

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131356129-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-131356129-1');
</script>
</html>
