<?
$this->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');

if($result_code == '0000') {
    echo '0000|||||';
    $row_count = count($list);
    if($row_count > 0) {

		foreach ($list as $val) {
			$idx                    = $val['idx'];
            $p_idx                  = $val['p_idx'];
            $s_idx                  = $val['s_idx'];
            $comment                = $val['comment'];
            $reg_date               = $val['reg_date'];
            $content_idx            = $val['content_idx'];
			$content_type         	= $val['content_type'];
			$main_img         	    = $val['main_img'];
			$title         	        = $val['title'];
			$column_name            = $val['column_name'];
			$like_count             = $val['like_count'];
			$bad_count              = $val['bad_count'];
			$reply_count            = $val['reply_count'];
			$write_id               = $val['write_id'];
			$comment_status         = $val['comment_status'];
            $comment_del_date 	    =  $val['del_date'];
            $is_best 	            =  $val['is_best'];
            if($column_name != '')  $title = '['.$column_name.'] '.$title;

            $user_comment_type = '<img src="/img/web/img_ballon.gif">';
            if($s_idx > 1) {
                $user_comment_type = '<span class="btn btn-default" style="padding: 1px 5px;">답글</span>';
            }

            $reg_date_txt  = substr($reg_date, 0, 16);

            switch ($content_type) {
                case '1': $view_url = '/web/news/news_view/'.$content_idx;	    $comment_url = '/web/news/news_comment/'.$content_idx; break;
                case '2': $view_url = '/web/news/column_view/'.$content_idx;    $comment_url = '/web/news/column_comment/'.$content_idx; break;
                case '3': $view_url = '/web/life/life_view/'.$content_idx;	    $comment_url = '/web/life/life_comment/'.$content_idx; break;
            }

            $comment_txt = $user_comment_type.' '.$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>BEST</label>'.$comment_txt;

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


	?>
            <div class="pop_cont_box_d">
                <input type="text" name="copy_user_comment_url<?=$idx?>" id="copy_user_comment_url<?=$idx?>" value="<?=WWW_CROSSMAP?><?=$comment_url?>"  style="position:absolute;top:-9999em;">
                <div class="pop_cont_title_d">
                    <?=$user_comment_type?> <?=$comment?>
                    <p class="popup_date_d"><?=$reg_date_txt?></p>
                </div>
                <div class="pop_cont_txt">
                    <span class="pop_cont_img2_d" style="width:14%;margin-top:10px; padding-bottom:10px;" >
                        <div onclick="location.href='<?=$view_url?>'" style="cursor:pointer;width:87px;height:60px;background:url('<?=$main_img?>') no-repeat center; background-size:cover;""></div>
                    </span>
                    <div class="pop_cont_txt_box_d" style="width:76%">
                        <p class="t_black"><a href="<?=$view_url?>"><?=$title?></a></p>
                        <p class="pop_replay_more_d"> <a href="<?=$comment_url?>">댓글 더보기</a></p>
                    </div>
                    <div class="pop_cont_info_d" style="width:10%">
                        <span class="fr"><a href="javascript:change_toggle('user_comment_info<?=$idx?>')"><img src="/img/web/pop_info.png"></a></span>
                        <ul class="info_popup_d" id="user_comment_info<?=$idx?>" style="display:none">
                    <?  if($comment_status=='1') {
                            if($comment_sns_id == $write_id) {?>
                                <li><a href="javascript:user_comment_del('<?=$idx?>');">삭제하기</a></li>
                    <?      } else {?>
                                <li><a href="javascript:user_comment_spam('<?=$idx?>', '<?=$write_id?>')">신고하기</a></li>
                    <?      }
                        }
                    ?>
                            <li style="border-top:1px solid #ededed"><a href="javascript:copy_user_comment_url('<?=$idx?>')">링크복사</a></li>
                        </ul>
                    </div>
                </div>
                <ul class="r_base_d">
                <?  if($p_idx == $idx) {?>
                    <li class="btn btn-default" style="padding: 1px 12px;" onclick="user_comment_reply_open('<?=$p_idx?>');" style="cursor: pointer;">답글 <?=number_format($reply_count)?></li>
                <?  }?>
                    <li class="icons_d">
                        <span class="thumbup_d"><a href="javascript:user_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_d"><a href="javascript:user_comment_like_select(2, '<?=$val['idx']?>')"><img src="/img/web/img_thumbdown.jpg"></a><span id="comment_like2_<?=$val['idx']?>"><?=number_format($bad_count)?></span></span>
                    </li>
                </ul>
            </div>
        <?  if($p_idx == $idx) {

                $comment_sns_img1 = '/img/web/img_cm_off.gif';		$comment_sns_class1 = 'fr';	$nameText1=""; 	$comment_sns_javascript1="change_toggle('login_layer');";	$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($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()";
                    //$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>".$comment_sns_name."</span>";	break;
                        case 'twitter':		$comment_sns_img2 = '/img/web/img_tweet.gif';		$comment_sns_class2 = '';	$nameText2="<span>".$comment_sns_name."</span>";	break;
                        case 'facebook':	$comment_sns_img3 = '/img/web/img_facebook_on.gif';	$comment_sns_class3 = '';	$nameText3="<span>".$comment_sns_name."</span>";	break;
                        case 'kakao':		$comment_sns_img4 = '/img/web/img_kakao_on.gif';	$comment_sns_class4 = '';	$nameText4="<span>".$comment_sns_name."</span>";	break;
                        case 'naver':		$comment_sns_img5 = '/img/web/img_naver_on.gif';	$comment_sns_class5 = '';	$nameText5="<span>".$comment_sns_name."</span>";	break;
                    }
                } else {
                    $comment_sns_class1 = '';$comment_sns_class2 = '';$comment_sns_class3 = '';$comment_sns_class4 = '';$comment_sns_class5 = '';
                }

        ?>
            <div class="reply_box2_d" id="user_comment_reply_box<?=$p_idx?>" style="display: none">
                <input type="hidden" name="user_comment_reply_page<?=$val['idx']?>" id="user_comment_reply_page<?=$val['idx']?>" value="1">
                <div id="user_comment_reply_list<?=$p_idx?>"></div>
                <ul class="box_wrap2">
                    <li style="width: 100%;text-align:right;font-size: 12px;padding-bottom:10px;display:none" id="user_comment_reply_more_btn<?=$idx?>" class="fr"><a href="<?=$comment_url?>">댓글 더보기 ></a></li>
                    <li class="r_img2" style="width: 2%; padding-right: 10px;"><img src="/img/web/img_reply1.gif"></li>
                    <li style="width: 95%;">
                        <div class="reply_box_d">
                            <div class="reply_social_d">

                            <a href="javascript:<?=$comment_sns_javascript1?>" style="cursor:<?=$comment_sns_cursor1?>"><span class="<?=$comment_sns_class1?>"><img src="<?=$comment_sns_img1?>"></span></a> <?=$nameText1?>
                            <a href="javascript:<?=$comment_sns_javascript2?>" style="cursor:<?=$comment_sns_cursor2?>"><span class="tweet <?=$comment_sns_class2?>"><img src="<?=$comment_sns_img2?>"></span></a> <?=$nameText2?>
                            <a href="javascript:<?=$comment_sns_javascript3?>" style="cursor:<?=$comment_sns_cursor3?>"><span class="facebook <?=$comment_sns_class3?>"><img src="<?=$comment_sns_img3?>"></span></a> <?=$nameText3?>
                            <a href="javascript:<?=$comment_sns_javascript4?>" style="cursor:<?=$comment_sns_cursor4?>"><span class="<?=$comment_sns_class4?>"><img src="<?=$comment_sns_img4?>"></span></a> <?=$nameText4?>
                            <a href="javascript:<?=$comment_sns_javascript5?>" style="cursor:<?=$comment_sns_cursor5?>"><span class="<?=$comment_sns_class5?>"><img src="<?=$comment_sns_img5?>"></span></a> <?=$nameText5?>

                            </div>
                            <div class="reply_write_d">
                                <textarea class="form-control <?=$reply_css2?> user_comment_text" <?=$content_readonly?> name="user_comment<?=$idx?>" id="user_comment<?=$idx?>" strA="<?=$idx?>" rows="3" placeholder="댓글 작성 시 상대방에 대한 배려와 사랑을 담아주세요." style="width:95%;"></textarea>
                            </div>
                            <div class="reply_regist_d"><span class="reply_no_d" id="user_reply_text_count<?=$p_idx?>">0/300</span><span class="reply_btn_d"><a href="javascript:user_comment_reply_add_proc('<?=$idx?>', '<?=$content_idx?>');"> 등록</a></span></div>
                        </div>
                    </li>
                </ul>
                <div class="reply_close_d"><a href="javascript:change_toggle('user_comment_reply_box<?=$p_idx?>')">댓글 접기</a> <img src="/img/web/img_replyclose.gif"></div>
            </div>
        <?  }?>



<?      }

    } else {
        echo '<div class="pop_cont_box_d" style="text-align: center">등록된 댓글이 없습니다.</div>';
    }
    echo '|||||'.$total_count.'|||||'.$more_list;

} else {
    echo $result_code.'|||||데이터 가져오기에 실패했습니다.';

}
?>
