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


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


if($result_code == '0000') {
    echo '0000|||||';
    if(count($arr_comment) == 0) {
        echo '<div style="height:100px;text-align:center; line-height:100px;">등록된 댓글이 없습니다.</div>';

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

        $i=1;
        foreach($arr_comment as $val) {
            $content_type 	    =  $val['content_type'];
            $comment_status 	=  $val['comment_status'];
            $comment_del_date 	=  $val['del_date'];
            $comment_reg_date 	=  $val['reg_date'];
            $c_sns_name 	    =  $val['sns_name'];
            $comment 	        =  $val['comment'];
            $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>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">
                <span class="beachblue">
                <?=$name_header?>
            <?
                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']?>');"><?=$val['write_name']?></a>
            <?
                    } else {
                        if($comment_sns_id!=$val['write_id']) {
                            echo $val['write_name'];
                        } else {
            ?>
                            <a href="javascript:user_comment('<?=$val['write_id']?>', '<?=$val['write_name']?>');"><?=$val['write_name']?></a>
            <?
                        }
                    }
                }
            ?>

                </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>
        <!-- 대댓글 -->

        <?php
            $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" 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">
                            <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">
                                <textarea class="form-control <?=$reply_css2?> comment_text" 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++;
        }?>
<?

    }



    echo '|||||'.$total_count.'|||||'.$more_list;

} else {
    echo $result_code.'|||||댓글가져오기를 실패했습니다.';

}
?>
