<?


$ci=& get_instance();

# session
$SES_MEMBER_ID              = $this->session->userdata('C_Member_Id');
$SES_MEMBER_NAME              = $this->session->userdata('C_Member_Name');

$SES_RANDOM_STATE = $this->session->userdata('RANDOM_STATE');
if ($SES_RANDOM_STATE == '') {
	$random_state = md5(microtime() . mt_rand());
	$this->session->set_userdata('RANDOM_STATE', $random_state);
	$SES_RANDOM_STATE = $this->session->userdata('RANDOM_STATE');
}

# 댓글
$req_data = array();
$req_data['content_type']   = $content_type;
$req_data['content_idx']    = $idx;
$req_data['offset']         = 0;
$req_data['limit']          = 15;
$req_data['sort_column']    = 'reg_date';
$req_data['sort_type']      = 'desc';
$req_data['write_id']       = $SES_MEMBER_ID;

$ci->load->library('comm');
$arr_comment_result = $ci->comm->fn_comment($req_data);

$comment_total_count        = $arr_comment_result['comment_total_count'];
$comment_my_delete_count    = $arr_comment_result['comment_my_delete_count'];
$arr_comment                = $arr_comment_result['arr_comment'];


$ci->load->helper('cookie');
$comment_sns_id 		= get_cookie('crossmap_comment_sns_id');
$comment_sns_name 		= get_cookie('crossmap_comment_sns_name');

$comment_sns_type 		= get_cookie('crossmap_comment_sns_type');

$comment_list_url = '';
$main_url = '';
if($content_type == '3') {
	$comment_list_url = '/m/life/life_comment/'.$idx;
	$main_url = '/m/life/life_view/'.$idx;
} else if($content_type == '2') {
	$comment_list_url = '/m/news/column_comment/'.$idx;
	$main_url = '/m/news/column_view/'.$idx;
} else if($content_type == '1') {
	$comment_list_url = '/m/news/news_comment/'.$idx;
	$main_url = '/m/news/news_view/'.$idx;
}

$method =  $this->uri->segment(3);
$is_comment_all_list = 'N';
if($method == 'life_comment' || $method == 'column_comment'|| $method == 'news_comment') {
	$is_comment_all_list = 'Y';
}

$ci=& get_instance();
$ci->load->model('web/m_member');
?>



        <div class="reply">
			<div class="reply_tit">댓글 <span class="beachblue" id="comment_count"><?=number_format($comment_total_count)?></span><span class="delete">본인 삭제 <span><?=number_format($comment_my_delete_count)?></span> <a href="javascript:comment_delete_refresh('<?=$idx?>', '<?=$SES_MEMBER_ID;?>', '<?=$content_type;?>');"><img src="/img/web/icon_refresh.gif"></a></span>

			<span class="btn-info fr" style="padding-left:10px; padding-top:1px;"><a href="javascript:;" class="comment_policy_btn"><img src="/img/web/icon_info.gif"></a></span>
			<span class="btn-tit fr"><a href="javascript:;" class="comment_policy_btn" style="color: #bcbcbc;">댓글운영정책</a></span>

			</div>

	<?

		if($comment_sns_id == '') {
			$reply_css2 = 'replay_text';
			$content_readonly = 'readonly';
		} else {
			$reply_css2 = '';
			$content_readonly = '';
		}


		$comment_sns_img1 = '/img/web/img_cm_off.gif';		$comment_sns_class1 = 'fr';	$nameText1=""; 	$comment_sns_javascript1="window.location='/m/member/login?redir=https://crossmap.co.kr".$_SERVER['REQUEST_URI']."'";	$comment_sns_cursor1 = 'pointer';
		$comment_sns_img2 = '/img/web/img_tweet_off.gif';	$comment_sns_class2 = 'fr';	$nameText2="";	$comment_sns_javascript2="twitter_join('comment')";			$comment_sns_cursor2 = 'pointer';
		$comment_sns_img3 = '/img/web/img_facebook_off.gif';$comment_sns_class3 = 'fr';	$nameText3="";	$comment_sns_javascript3="checkLoginState();";				$comment_sns_cursor3 = 'pointer';
		$comment_sns_img4 = '/img/web/img_kakao_off.gif';	$comment_sns_class4 = 'fr';	$nameText4="";	$comment_sns_javascript4="kakako_login()";					$comment_sns_cursor4 = 'pointer';
		$comment_sns_img5 = '/img/web/img_naver_off.gif';	$comment_sns_class5 = 'fr';	$nameText5="";	$comment_sns_javascript5="naver_login()";					$comment_sns_cursor5 = 'pointer';



		 if ( $SES_MEMBER_ID  ){
			$comment_sns_type = "cm";
//			 $comment_sns_name = $SES_MEMBER_NAME;

		 }



		 if(isset($comment_sns_type)) {
		 	$comment_sns_javascript1 = "logout_advice()";$comment_sns_javascript2 = "logout_advice()";	$comment_sns_javascript3 = "logout_advice()";	$comment_sns_javascript4 = "logout_advice()";	$comment_sns_javascript5 = "logout_advice()";
		 }
         
         if($comment_sns_name) {
            if(mb_strlen($comment_sns_name, 'utf-8') > 5) {
                $comment_sns_name = mb_strcut($comment_sns_name, 0, 9, 'UTF-8')."**";
            } 
         }
			//$comment_sns_cursor1 = "default";		$comment_sns_cursor2 = "default";		$comment_sns_cursor3 = "default";		$comment_sns_cursor4 = "default";		$comment_sns_cursor5 = "default";
			switch ($comment_sns_type) {
				case 'cm':			$comment_sns_img1 = '/img/web/img_cm_on.gif';		$comment_sns_class1 = '';	$nameText1='<span style="display:inline-block; vertical-align:top;">'.$comment_sns_name.'<span style="color:#a7a7a7;padding-left:10px;font-size:11px"><a href="javascript:window.location=\'/m/member/logout_proc\';">로그아웃</a> </span></span>';	break;
				case 'twitter':		$comment_sns_img2 = '/img/web/img_tweet.gif';		$comment_sns_class2 = '';	$nameText2='<span style="display:inline-block; vertical-align:top;">'.$comment_sns_name.'<span style="color:#a7a7a7;padding-left:10px;font-size:11px"><a href="javascript:comment_logout();">로그아웃</a> </span></span>';	break;
				case 'facebook':	$comment_sns_img3 = '/img/web/img_facebook_on.gif';	$comment_sns_class3 = '';	$nameText3='<span style="display:inline-block; vertical-align:top;">'.$comment_sns_name.'<span style="color:#a7a7a7;padding-left:10px;font-size:11px"><a href="javascript:comment_logout();">로그아웃</a> </span></span>';	break;
				case 'kakao':		$comment_sns_img4 = '/img/web/img_kakao_on.gif';	$comment_sns_class4 = '';	$nameText4='<span style="display:inline-block; vertical-align:top;">'.$comment_sns_name.'<span style="color:#a7a7a7;padding-left:10px;font-size:11px"><a href="javascript:comment_logout();">로그아웃</a> </span></span>';	break;
				case 'naver':		$comment_sns_img5 = '/img/web/img_naver_on.gif';	$comment_sns_class5 = '';	$nameText5='<span style="display:inline-block; vertical-align:top;">'.$comment_sns_name.'<span style="color:#a7a7a7;padding-left:10px;font-size:11px"><a href="javascript:comment_logout();">로그아웃</a> </span></span>';	break;
			}



	?>

			<div class="reply_box">
				<div class="reply_social">
							<?switch($comment_sns_type){
								case 'cm': ?>
									<a href="javascript:<?=$comment_sns_javascript1?>" style="cursor:<?=$comment_sns_cursor1?>"><span class="tweet"><img src="<?=$comment_sns_img1?>"></a> <?=$nameText1?>
									<?;break;?>
								<?case 'twitter': ?>
									<a href="javascript:<?=$comment_sns_javascript2?>" style="cursor:<?=$comment_sns_cursor2?>"><img src="<?=$comment_sns_img2?>"></a> <?=$nameText2?>
									<?;break;?>
								<?case 'facebook': ?>
									<a href="javascript:<?=$comment_sns_javascript3?>" style="cursor:<?=$comment_sns_cursor3?>"><img src="<?=$comment_sns_img3?>"></a> <?=$nameText3?>
									<?;break;?>
								<?case 'kakao': ?>
									<a href="javascript:<?=$comment_sns_javascript4?>" style="cursor:<?=$comment_sns_cursor4?>"><img src="<?=$comment_sns_img4?>"></a> <?=$nameText4?>
									<?;break;?>
								<?case 'naver': ?>
									<a href="javascript:<?=$comment_sns_javascript5?>" style="cursor:<?=$comment_sns_cursor5?>"><img src="<?=$comment_sns_img5?>"></a> <?=$nameText5?>
									<?;break;?>
								<?}?>



							<span class="facebook<?=($comment_sns_type) ? " on" : ""; ?>">
                                <a href="javascript:<?=$comment_sns_javascript5?>" style="cursor:<?=$comment_sns_cursor5?>;<?=($comment_sns_type == 'naver')? "display:none" : ""?>"><img src="<?=$comment_sns_img5?>"></a>
                                <a href="javascript:<?=$comment_sns_javascript4?>" style="cursor:<?=$comment_sns_cursor4?>;<?=($comment_sns_type == 'kakao')? "display:none" : ""?>"><img src="<?=$comment_sns_img4?>"></a>
                                <a href="javascript:<?=$comment_sns_javascript3?>" style="cursor:<?=$comment_sns_cursor3?>;<?=($comment_sns_type == 'facebook')? "display:none" : ""?>"><img src="<?=$comment_sns_img3?>"></a>
                                <a href="javascript:<?=$comment_sns_javascript2?>" style="cursor:<?=$comment_sns_cursor2?>;<?=($comment_sns_type == 'twitter')? "display:none" : ""?>"><img src="<?=$comment_sns_img2?>"></a>
                                <a href="javascript:<?=$comment_sns_javascript1?>" style="cursor:<?=$comment_sns_cursor1?>;<?=($comment_sns_type == 'cm')? "display:none" : ""?>"><span class="tweet"><img src="<?=$comment_sns_img1?>"></span></a>
							</span>
				</div>


				<div class="reply_write">
					<textarea style="width:90% !important" class="form-control <?=$reply_css2?> comment_text" name="comment" id="comment" rows="3" strA="" <?=$content_readonly?> placeholder="댓글 작성 시, 상대방에 대한 배려와 사랑을 담아주세요." style="width:100%;" ></textarea>
				</div>
				<div class="reply_regist"><span class="reply_no" id="reply_text_count">0/300</span><span class="reply_btn" onclick="comment_add_proc();" style="cursor: pointer">등록</span></div>
			</div>
			<div class="reply_sort">
				<input type="hidden" name="comment_sort" id="comment_sort" value="1">
				<span><a href="javascript:change_comment_sort(1);" id="comment_sort1">호감순</a></span><span><a href="javascript:change_comment_sort(2);" class="current" id="comment_sort2">최신순</a></span>
			<?	if($is_comment_all_list == 'Y') { ?>
				<span><a href="javascript:change_comment_sort(3);" id="comment_sort3">과거순</a></span><span><a href="javascript:change_comment_sort(4);" id="comment_sort4">답글순</a></span>
			<?	}?>
			</div>
			<div class="reply_contents">
				<ul class="reply_list">
					<div class="comment_box" >
						<div id="comment_list">
				<?
					if(count($arr_comment) == 0) {
						echo '<div style="height:100px;text-align:center; line-height:100px;">등록된 댓글이 없습니다.</div>';

					} else{
						$i=1;
						foreach($arr_comment as $count=>$val) {
							if($count < 14 )break;
							$content_type 	    =  $val['content_type'];
							$comment_status 	=  $val['comment_status'];
							$comment 			=  $val['comment'];
							$comment_del_date 	=  $val['del_date'];
							$c_sns_name 		=  $val['sns_name'];
							$comment_reg_date 	=  $val['reg_date'];
							$is_best 			=  $val['is_best'];
							$write_id 			=  $val['write_id'];
							$comment_reg_date 	=  substr($comment_reg_date, 0, 10);

							$comment_main_style = '';
							if($i == count($arr_comment) && $is_comment_all_list == 'Y') {
								$comment_main_style= 'style="border-bottom:0 !important"';
							}

							$comment_txt = $comment;
							if($comment_status!='1') {
								$comment_txt = '<div style="color:#bcbcbc;"><img src="/img/web/icon_info.gif"> '.$comment.'</div><div class="r_date" style="margin-top:5px;color:#bcbcbc;">'.$comment_del_date.'</div>';
							}
							if($is_best=='Y')   $comment_txt = '<label style="border-radius: 3px;margin-left:0;padding: 2px 4px;color: #fff;background: #e64c3d;display: inline-block;margin-right: 5px;font-size: 11px;">BEST</label>'.$comment_txt;


							$arr_member = $ci->m_member->member_where_member_id_select($write_id);
							$member_img = '/img/web/img_profile_l.png';
							if(isset($arr_member['member_img'])==true) 	$member_img = $arr_member['member_img'];

							$name_header = '<img src="'.$member_img.'" width="16" height="16">&nbsp;&nbsp;';
							if($c_sns_name !='cm') {
								$name_header = '<img src="/img/web/img_'.$c_sns_name.'_on.gif">&nbsp;&nbsp;';
							}

					?>
						<div class="reply_comment" id="reply_comment_main<?=$val['idx']?>" <?=$comment_main_style?>>
							<div class="r_info">
								<?=$name_header?>
								<span class="beachblue">
								<?
								if($comment_sns_id == '') {
									echo $val['write_name'];
								} else {
									if($content_type=='1' || $content_type=='2') {?>
										<a href="javascript:user_comment('<?=$val['write_id']?>', '<?=$val['write_name']?>');" style="color: #2bbec6 !important;"><?=$val['write_name']?></a>
								<? 	} else {
										if($comment_sns_id==$val['write_id']) {
								?>
											<a href="javascript:user_comment('<?=$val['write_id']?>', '<?=$val['write_name']?>');" style="color: #2bbec6 !important;"><?=$val['write_name']?></a>
								<?
										} else {
											echo $val['write_name'];
										}
									}
								}
								?>

								</span>
								<span class="r_date">
									<?=$comment_reg_date?>
									<? if($comment_status==1) {?>
										<? if($comment_sns_id!=$val['write_id']){?><span style="color:#e1e2e2;padding-left:10px;"> |</span> <a href="javascript:comment_spam('<?=$val['idx']?>', '<?=$val['write_name']?>')">신고</a><? } ?>
										<? if($comment_sns_id==$val['write_id']){?><span style="color:#e1e2e2;padding-left:10px;"> |</span> <a href="javascript:comment_del('<?=$val['idx']?>')">삭제</a><?}?>
									<?	}?>
								</span>
							</div>
							<div class="r_text"><?=$comment_txt?></div>
							<ul class="r_base">
								<li class="btn btn-default" onclick="comment_reply_open('<?=$val['idx']?>');" style="color:#000000;cursor: pointer">답글 <span id="comment_reply_count<?=$val['idx']?>"><?=number_format($val['reply_count'])?></span></li>
								<li class="icons">
									<span class="thumbup"><a href="javascript:comment_like_select(1, '<?=$val['idx']?>');"><img src="/img/web/img_thumbup.jpg"></a><span id="comment_like1_<?=$val['idx']?>"><?=number_format($val['like_count'])?></span></span>
									<span class="thumbdown"><a href="javascript:comment_like_select(2, '<?=$val['idx']?>');"><img src="/img/web/img_thumbdown.jpg"></a><span id="comment_like2_<?=$val['idx']?>"><?=number_format($val['bad_count'])?></span></span>
								</li>
							</ul>
						</div>
						<!-- 대댓글 -->
						<div class="reply_box2" id="reply_comment<?=$val['idx']?>" style="display:none">
							<div id="reply_comment_list<?=$val['idx']?>"></div>
							<input type="hidden" name="comment_reply_page<?=$val['idx']?>" id="comment_reply_page<?=$val['idx']?>" value="1">
							<div class="reply_close" id="reply_more<?=$val['idx']?>" style="display:none;"><a href="javascript:comment_reply_more(<?=$val['idx']?>)">더보기</a> <img src="/img/web/img_replyopen.gif"></div>

							<ul class="box_wrap2">
								<li class="r_img2"><img src="/img/web/img_reply1.gif"></li>
								<li>
									<div class="reply_box">
										<div class="reply_social">
                                            <div class="user">
                                                Username
                                            </div>
											<?switch($comment_sns_type){
												case 'cm': ?>
													<a href="javascript:<?=$comment_sns_javascript1?>" style="cursor:<?=$comment_sns_cursor1?>"><span class="tweet"><img src="<?=$comment_sns_img1?>"><?=$nameText1?></span></a>
													<?;break;?>
												<?case 'twitter': ?>
													<a href="javascript:<?=$comment_sns_javascript2?>" style="cursor:<?=$comment_sns_cursor2?>"><img src="<?=$comment_sns_img2?>"></a> <?=$nameText2?>
													<?;break;?>
												<?case 'facebook': ?>
													<a href="javascript:<?=$comment_sns_javascript3?>" style="cursor:<?=$comment_sns_cursor3?>"><img src="<?=$comment_sns_img3?>"></a> <?=$nameText3?>
													<?;break;?>
												<?case 'kakao': ?>
													<a href="javascript:<?=$comment_sns_javascript4?>" style="cursor:<?=$comment_sns_cursor4?>"><img src="<?=$comment_sns_img4?>"></a> <?=$nameText4?>
													<?;break;?>
												<?case 'naver': ?>
													<a href="javascript:<?=$comment_sns_javascript5?>" style="cursor:<?=$comment_sns_cursor5?>"><img src="<?=$comment_sns_img5?>"></a> <?=$nameText5?>
													<?;break;?>
												<?}?>

<!--a href="#">로그아웃</a-->

											<span class="facebook">
												<a href="javascript:<?=$comment_sns_javascript5?>" style="cursor:<?=$comment_sns_cursor5?>;<?=($comment_sns_type == 'naver')? "display:none" : ""?>"><img src="<?=$comment_sns_img5?>"></a>
												<a href="javascript:<?=$comment_sns_javascript4?>" style="cursor:<?=$comment_sns_cursor4?>;<?=($comment_sns_type == 'kakao')? "display:none" : ""?>"><img src="<?=$comment_sns_img4?>"></a>
												<a href="javascript:<?=$comment_sns_javascript3?>" style="cursor:<?=$comment_sns_cursor3?>;<?=($comment_sns_type == 'facebook')? "display:none" : ""?>"><img src="<?=$comment_sns_img3?>"></a>
												<a href="javascript:<?=$comment_sns_javascript2?>" style="cursor:<?=$comment_sns_cursor2?>;<?=($comment_sns_type == 'twitter')? "display:none" : ""?>"><img src="<?=$comment_sns_img2?>"></a>
												<a href="javascript:<?=$comment_sns_javascript1?>" style="cursor:<?=$comment_sns_cursor1?>;<?=($comment_sns_type == 'cm')? "display:none" : ""?>"><span class="tweet"><img src="<?=$comment_sns_img1?>"></span></a>




							</span>

										</div>
											<div class="reply_write">
												<textarea  style="width:90% !important" class="form-control <?=$reply_css2?> comment_text" <?=$content_readonly?> name="comment<?=$val['idx']?>"  id="comment<?=$val['idx']?>" strA="<?=$val['idx']?>" rows="3" placeholder="댓글 작성 시, 상대방에 대한 배려와 사랑을 담아주세요." style=" width: 590px;"></textarea>
											</div>
										<div class="reply_regist">
											<span class="reply_no" id="reply_text_count<?=$val['idx']?>">0/300</span><span class="reply_btn"><a href="javascript:comment_reply_add_proc(<?=$val['idx']?>);"> 등록</a></span>
										</div>
									</div>
								</li>
							</ul>
							<div class="reply_close"><a href="javascript:comment_reply_close('<?=$val['idx']?>')">댓글 접기</a> <img src="/img/web/img_replyclose.gif"></div>
						</div>
						<!--// 대댓글 -->

					<?
							$i++;
						}
					}
						?>
						</div>

					<?	if($is_comment_all_list == 'Y') {
							$comment_more_btn_style = 'style="display:none;"';
							if($comment_total_count > count($arr_comment)) {
								$comment_more_btn_style = ' style="display:block;"';
							}

					?>
						<div class="channel_bottom3">
							<button type="button" class="btn btn-default br20" id="comment_more_btn" <?=$comment_more_btn_style?> onclick="comment_list_more();">더보기 </button>
						</div>
				<?		}


					?>

					<?	if($is_comment_all_list == 'Y') { ?>
						<div class="reply_info" style="float:right; padding:0 0 30px 0;">
							<span><img src="/img/web/mypage_arrow_left.gif"  style="padding-top:9px;"> <a href="<?=$main_url?>" style="color:#7e7f82"> 이전 페이지로 돌아가기</a> </span>

							<span style="color:#d4d4d4;padding-left:10px;"> |</span>
							<span><img src="/img/web/img_up2.gif"  style="padding-top:12px;"><a href="#" style="color:#7e7f82"> 맨위로</a></span>
						</div>
					<?	} else {

							$comment_all_list_style = '';
							if($comment_total_count==0)	$comment_all_list_style='display:none;';

					?>
						<div class="viewall" id="comment_all_list" style="float:right; padding:20px 0 30px 0;<?=$comment_all_list_style?>"><a href="<?=$comment_list_url?>">전체 댓글 보기 &gt;</a></div>
					<?	} ?>
					</div>
				</ul>
			</div>
		</div>

<div class="delivery_info2" style="display:none;">
	<p class="d_info_tit" style="text-align:center; margin:10px 0">댓글운영정책</p>
	<p class="d_info_txt">
		크로스맵 댓글은 게시물에 대하여 자신의 생각을 말하고 남의 생각을 들으며 서로 다양한 의견을 나누는 공간입니다. 그러나 간혹 불건전한 내용을 올리시는 분들이 계셔서 건전한 인터넷문화 정착을 위해 아래와 같은 운영원칙을 적용합니다.<br><br>
		<span style="text-decoration:underline; margin-bottom: 15px;display: inline-block;">1. 댓글의 삭제 및 제한 조치</span><br>
		네티즌들의 신고 또는 자제 모니터링을 통해 아래에 해당하는 내용이 포함된 댓글이 발견되면 예고없이 삭제 또는 제한 조치를 하겠습니다. <br>
	</p>
	<table style="font-size:13px;">
		<tbody>
		<tr>
			<td>1) 타인에 대한 욕설 또는 비방 </td>
			<td>2) 인신공격 또는 명예훼손 </td>
		</tr>
		<tr>
			<td>3) 개인정보 유출 또는 사생활 침해</td>
			<td>4) 음란성 내용 또는 음란물 링크 </td>
		</tr>
		<tr>
			<td>5) 상업적 광고 또는 사이트/홈피 홍보&nbsp;&nbsp;&nbsp;</td>
			<td>6) 불법정보 유출</td>
		</tr>
		<tr>
			<td>7) 같은 내용의 반복(도배) </td>
			<td>8) 폭력 또는 사행심 조장 </td>
		</tr>
		<tr>
			<td>9) 기타 게시물 내용과 관계없는 내용</td>
			<td></td>
		</tr>
		</tbody>
	</table>
	<br>
	<p class="d_info_txt">

		<span style="text-decoration:underline; margin-bottom: 15px;display: inline-block;">2. 댓글 작성에 대한 제한</span><br>

		불건전한 댓글은 발견시 별도의 통보없이 즉시 삭제 또는 제한 조치 하며 상습적 또는 위반 정도가 심한 댓글을 올리시는 분에 대해서는 일정 기간 댓글 작성에 대한 권한을 제한할 수 있습니다.<br>
		또한 비정상적인 패턴으로 조회, 추천, 반대 등이 발생하는 것으로 관리자 또는 시스템이 판단하는
		경우 부정 클릭여부를 확인하여 해당 IP나 ID를 제재할 수 있습니다.<br>
		명예훼손, 개인정보유츨, 욕설 등 법률에 위반되는 댓글은 관계 법령에 의거 민형사상 처벌을 받을 수 있으니 이용에 주의를 부탁 드립니다.<br><br></p>
	<p class="d_info_txt">
		<span style="text-decoration:underline; margin-bottom: 15px;display: inline-block;">3. 뉴스, 칼럼 댓글함 전체공개</span><br>

		건전한 댓글 문화를 위하여 뉴스 및 칼럼 댓글에 한해서만 댓글모음이 전체공개됩니다. 제공되는 목록에 삭제한 댓글이나 답글은 포함되지 않습니다. <br>
	</p>
	<div class="form-group" style="margin:20px 0; display:block; text-align:center; border-bottom:0">
		<button type="button" class="btn btn-success" style="padding:5px 20px; font-size:14px" onclick='$(".delivery_info2").toggle();' style="cursor:pointer;">확인</button>
	</div>
</div>
<!---->
<!--<div id="comment_policy" style="display:none;z-index: 9999">-->
<!--<div class="delivery_info3" style="position: fixed;">-->
<!--	<p class="d_info_tit" style="text-align:center; margin:10px 0">댓글운영정책</p>-->
<!--	<p class="d_info_txt">-->
<!---->
<!--	크로스맵 댓글은 게시물에 대하여 자신의 생각을 말하고 남의 생각을 들으며 서로 다양한 의견을 나누는 공간입니다. 그러나 간혹 불건전한 내용을 올리시는 분들이 계셔서 건전한 인터넷문화 정착을 위해 아래와 같은 운영원칙을 적용합니다.<br><br>-->
<!---->
<!--						<span style="text-decoration:underline; margin-bottom: 15px;display: inline-block;">1. 댓글의 삭제 및 제한 조치</span><br>-->
<!---->
<!--	네티즌들의 신고 또는 자제 모니터링을 통해 아래에 해당하는 내용이 포함된 댓글이 발견되면 예고없이 삭제 또는 제한 조치를 하겠습니다. <br>-->
<!--	</p>-->
<!--	<table style="font-size:13px;">-->
<!--	<tr>-->
<!--		<td>1) 타인에 대한 욕설 또는 비방 </td>-->
<!--		<td>2) 인신공격 또는 명예훼손 </td>-->
<!--	</tr>-->
<!--	<tr>-->
<!--		<td>3) 개인정보 유출 또는 사생활 침해</td>-->
<!--		<td>4) 음란성 내용 또는 음란물 링크 </td>-->
<!--	</tr>-->
<!--	<tr>-->
<!--		<td>5) 상업적 광고 또는 사이트/홈피 홍보&nbsp;&nbsp;&nbsp;</td>-->
<!--		<td>6) 불법정보 유출</td>-->
<!--	</tr>-->
<!--	<tr>-->
<!--		<td>7) 같은 내용의 반복(도배) </td>-->
<!--		<td>8) 폭력 또는 사행심 조장 </td>-->
<!--	</tr>-->
<!--	<tr>-->
<!--		<td>9) 기타 게시물 내용과 관계없는 내용</td>-->
<!--		<td></td>-->
<!--	</tr>-->
<!--	</table>-->
<!--	<br><br>-->
<!--	<p class="d_info_txt">-->
<!---->
<!--	<span style="text-decoration:underline; margin-bottom: 15px;display: inline-block;">2. 댓글 작성에 대한 제한</span><br>-->
<!---->
<!--	불건전한 댓글은 발견시 별도의 통보없이 즉시 삭제 또는 제한 조치 하며 상습적 또는 위반 정도가 심한 댓글을 올리시는 분에 대해서는 일정 기간 댓글 작성에 대한 권한을 제한할 수 있습니다.<br>-->
<!--	또한 비정상적인 패턴으로 조회, 추천, 반대 등이 발생하는 것으로 관리자 또는 시스템이 판단하는-->
<!--	경우 부정 클릭여부를 확인하여 해당 IP나 ID를 제재할 수 있습니다.<br>-->
<!--	명예훼손, 개인정보유츨, 욕설 등 법률에 위반되는 댓글은 관계 법령에 의거 민형사상 처벌을 받을 수 있으니 이용에 주의를 부탁 드립니다.<br><br>-->
<!---->
<!--	<span style="text-decoration:underline; margin-bottom: 15px;display: inline-block;">3. 뉴스, 칼럼 댓글함 전체공개</span><br>-->
<!---->
<!--	건전한 댓글 문화를 위하여 뉴스 및 칼럼 댓글에 한해서만 댓글모음이 전체공개됩니다. 제공되는 목록에 삭제한 댓글이나 답글은 포함되지 않습니다. <br>-->
<!--	</p>-->
<!--	<div class="form-group" style="margin:20px 0; display:block; text-align:center">-->
<!--		<button type="button" class="btn btn-success" onclick="change_toggle('comment_policy');" style="padding:5px 20px; font-size:14px">확인</button>-->
<!--	</div>-->
<!---->
<!--</div>-->
<!--<div class="mask" style="z-index: 9998"></div>-->
<!--</div>-->


<div id="social_login" style="display:none;">
<div class="popup_wrap popup_wrap2" style="width:300px;position:fixed;">

		<div class="popupbox txc">
			<div class="popuptop">
				<h3 class="p_title">소셜댓글 로그인</h3>
				<span class="btn-close"><a href="javascript:;" onclick="$('.popup_wrap').hide(); $('.mask').hide();"><img src="/img/mobile/btn-close.png"></a></span>
			</div>
			<div class="popupbody">
				<div class="ft14" style="padding:30px 0 20px;">계정을 선택하시면 <span class="beachblue">로그인·계정인증</span>을 통해
					댓글을 남기실 수 있습니다.</div>
				<div>
					<a style="cursor:pointer;" onclick="window.location='/m/member/login?redir='+window.location.href"><img src="/img/mobile/btn_crossmap.gif" alt="크로스맵"></a>
				</div>
				<div>
					<a href="javascript:twitter_join('comment')"><img src="/img/mobile/btn_tweet.gif" alt="트위터"></a>
				</div>
				<div>
					<a href="javascript:kakako_login();"><img src="/img/mobile/btn_kakao.png" alt="카카오톡"></a>
				</div>
                <div>
					<a href="javascript:naver_login();"><img src="/img/mobile/btn_naver.png" alt="네이버"></a>
				</div>
                <div style="margin-bottom:20px;">
					<a href="javascript:checkLoginState()"><img src="/img/mobile/btn_facebook.gif" alt="페이스북"></a>
				</div>
			</div>
		</div>


</div>
<div class="mask"></div>
</div>

<!-- 댓글 신고 -->
<? require_once(APPPATH . "views/m/common/comment_spam_layer_inc.php");?>


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


});

$('.comment_policy_btn').click(function(e) {
	// $("#comment_policy").toggle();
    // var popH = $(this).offset().top;
    // $('.delivery_info3').css('left','50%');
	// $('.delivery_info3').css('top', '70px');
	// $('.delivery_info3').css('margin-left','-265px');
	$(".delivery_info2").toggle();
	$("html, body").scrollTop(0);


	// console.log(popH);

});


$('.replay_text').click(function(e) {
	$("#social_login").show();
    var popH = $(this).offset().top;
    $(".popup_wrap").css('left','50%');
	$(".popup_wrap").css('top','100px');
	//$("html, body").scrollTop(0);

});


$('.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;
   	}
   	$("#reply_text_count"+key).html(len+'/300');
});



// 댓글
// 댓글 sort 변경
function change_comment_sort(type){
	$("#comment_sort").val(type);
	$("#comment_sort1").removeClass('current');
	$("#comment_sort2").removeClass('current');
	$("#comment_sort3").removeClass('current');
	$("#comment_sort4").removeClass('current');
	$("#comment_sort"+type).addClass('current');
	comment_list(1);
}

// 대댓글 열기
function comment_reply_open(idx){
	$("#reply_comment"+idx).toggle();
	// $("#reply_comment_main"+idx).addClass('reply_comment_open');
	// $("#reply_comment_main"+idx).removeClass('reply_comment');

	comment_reply_list(idx, 1);
	$("#comment_reply_page"+idx).val(1);
}

// 대댓글 닫기
function comment_reply_close(idx){
	$("#reply_comment"+idx).hide();

	$("#reply_comment_main"+idx).removeClass('reply_comment_open');
	$("#reply_comment_main"+idx).addClass('reply_comment');
}

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

}

// 댓글 더보기
var comment_page = 2;
function comment_list_more(){
	comment_list(comment_page);
}

function comment_list(page){
	var sort = $("#comment_sort").val();
	var form_data = {
		"sort"					: sort,
		"page"					: page,
		"content_idx"			: "<?=$idx?>",
		"content_type"			: "<?=$content_type?>",
		"is_comment_all_list"	: "<?=$is_comment_all_list?>"
	};
	$.ajax({
        url: '/web/comm/comment_list',
        async: false,
        type: 'POST',
		timeout: 10000,
        dataType: 'HTML',
        data: form_data,
        success: function (rtnHtml) {
        	if(rtnHtml=='') return false;
			var arrHtml = rtnHtml.split("|||||");
			if(arrHtml[0].trim()=='0000') {
				if(page == 1) {
					$("#comment_list").html(arrHtml[1]);
				} else {
					$("#comment_list").children('.reply_comment').last().removeAttr("style");
					$("#comment_list").append(arrHtml[1]);
				}
				$("#comment_count").html(setComma(arrHtml[2]));
				if (arrHtml[3] == "N") {
					$("#comment_more_btn").hide();
				} else {
					$("#comment_more_btn").show();
				}
				<? if($is_comment_all_list=='N') {?>

					if(parseInt(arrHtml[2]) > 0) {
						console.log("1");
						$("#comment_all_list").show();
					}
				<?	}?>
				comment_page=page+1;

			} else {
				// alert(arrHtml[1]);
               	return false;
			}
        },
        error: function (rtnHtml) {
            //alert('저장에 실패했습니다.');
            return false;
        }
    });
}


// comment 댓글 리스트 가져오기
function comment_reply_list(idx, page){
	var sort = $("#comment_sort").val();
	var form_data = {
		"comment_idx"			: idx,
		"page"					: page,
		"sort"					: sort
	};
	$.ajax({
        url: '/web/comm/comment_reply_list',
        async: false,
        type: 'POST',
        dataType: 'HTML',
		timeout: 10000,
		data: form_data,
		success: function (rtnHtml) {
        	var arrHtml = rtnHtml.split("|||||");
			if(arrHtml[0].trim()=='0000') {
				if (arrHtml[1] != "") {
					if(page==1) {
						$("#reply_comment_list" + idx).html(arrHtml[1]);
					} else {
					    $("#reply_comment_list" + idx).append(arrHtml[1]);
					}
				}

				$("#comment_reply_count"+idx).html(setComma(arrHtml[2]));
				if (arrHtml[3] == "N") {
					$("#reply_more" + idx).hide();
				} else {
					$("#reply_more" + idx).show();
				}
			}
        },
        error: function (rtnHtml) {
            //alert('데이터 로드에 실패했습니다.');
            return false;
        }
    });
}



// 댓글달기
function comment_add_proc(){
	if("<?=$comment_sns_id?>"=="") {
		alert("로그인 후에 이용가능합니다.");
		return;
	}

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

	var form_data = {
		"content_idx"			: "<?=$idx?>",
		"content_type"			: "<?=$content_type?>",
		"comment"				: $("#comment").val()
	};
	$.ajax({
        url: '/web/comm/comment_add_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
        	if (rtnJson.code == "0000") {
				$("#comment").val('');
				$("#comment").focus();
				$("#reply_text_count").html('0/300');

				$("#comment_sort").val('2');
				$("#comment_sort1").removeClass('current');
				$("#comment_sort2").removeClass('current');
				$("#comment_sort2").addClass('current');

				comment_list(1);



            } else {
                alert(rtnJson.msg);
                return false;
            }

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



// 대대글 달기
function comment_reply_add_proc(p_idx){
	if("<?=$comment_sns_id?>"=="") {
		alert("로그인 후에 이용가능합니다.");
		return;
	}

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

	var form_data = {
		"p_idx"					: p_idx,
		"content_idx"			: "<?=$idx?>",
		"content_type"			: "<?=$content_type?>",
		"comment"				: $("#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") {
				$("#comment"+p_idx).val('');
				$("#reply_text_count"+p_idx).html('0/300');
				$("#comment_reply_page"+p_idx).val(1);

				$("#comment_sort").val('2');
				$("#comment_sort1").removeClass('current');
				$("#comment_sort2").removeClass('current');
				$("#comment_sort2").addClass('current');

				comment_reply_list(p_idx, 1);

            } else {
                alert(rtnJson.msg);
                return false;
            }

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


    });

}

// 댓글 좋아요
function comment_like_select(type, idx){
	if("<?=$comment_sns_id?>"=="") {
        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 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") {
                comment_list(1);

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

}


function 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") {
            	comment_reply_list(p_idx, 1);
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('삭제에 실패했습니다.');
            return false;
        }
    });

}


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

function comment_logout(){
	location.href="/web/comm/comment_logout";
}

// 크로스맵으로 가입
function crossmap_join() {

	commonLayerClose('member_join1_layer');
	commonLayerOpen('member_join2_layer');
}

// 트위터로 가입
function twitter_join(val) {

	var form_data = {
		"type": val
	};
	$.ajax({
		url: '/web/comm/twitter_request_token',
		async: false,
		type: 'POST',
		dataType: 'JSON',
		data: form_data,
		success: function (rtnJson) {
			if (rtnJson.result_code == "0000") {
				var url = rtnJson.result_data.url;
				console.log(url);
				window.open(url, "", "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes");

			} else {
				alert("트위터 계정인증에 실패했습니다.");
				return false;
			}
		},
		error: function (rtnJson) {
			alert('트위터 계정인증에 실패했습니다.');
			return false;
		}
	});
}

//  카카오로 가입
function kakako_login() {


	var state = "<?=$SES_RANDOM_STATE?>";
	var url = "https://kauth.kakao.com/oauth/authorize?client_id=d9d530edc95295682137fdd37dddc55f&redirect_uri=<?=WWW_CROSSMAP?>/web/share/kakao_callback_proc&response_type=code&state=" + state;
	window.open(url, "", "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes");
}

// 네이버로 가입
function naver_login() {


	var state = "<?=$SES_RANDOM_STATE?>";
	var url = "https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=cNiinVHYsygxVKF4FOtw&redirect_uri=<?=WWW_CROSSMAP?>/web/share/naver_callback_proc&state=" + state;
	window.open(url, "", "height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes");
}

function checkLoginState() {
	window.FB.login(function(response) {
		console.log(response);
		if (response.status === 'connected') {
			statusChangeCallback(response);
		}
	});
}
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);
		}
	});
}

function comment_delete_refresh(idx, write_id, content_type) {
    var form_data = {
        "idx"			: idx,
        "write_id"      : write_id,
        "content_type"      : content_type
    };
    $.ajax({
        url: '/web/life/user_comment_refresh_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {            
            if (rtnJson.result.code == "0000") {
            	$('.delete span').text(rtnJson.delete_cnt);
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('알 수 없는 오류가 발생하였습니다.');
            return false;
        }
    });
}


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'));





	function user_comment(write_id, write_name){

	<?


		switch($ci->router->fetch_class()){
			case "life":
				$type = 3;
				break;
			case "news":
				$type = 1;
				break;
			default :
				$type = 2;
				break;
		}


//		echo 'console.log("'.$a.'");';

		?>
		var type = <?=$type;?>;
		window.location = `/m/mypage/user_comment?id=${write_id}&nick=${write_name}&type=${type}`;
	}


</script>
