<?
$ci=& get_instance();

# 테마
$ci->load->model('web/m_theme');
$req_data = array();
$req_data['theme_types'] = array('4', '14');
$arr_theme = $ci->m_theme->theme_join_vw_content_where_in_theme_type_list($req_data);

$arr_today_photo  = array();
$i=1;$z=1;
foreach ($arr_theme as $val) {
	if($val['theme_type'] == 4)     $arr_today_photo[$val['rank']]  = array('rank'=>$val['rank'], 'title' => $val['title'], 'sub_content' => $val['sub_content'], 'theme_img' => $val['theme_img'], 'content_idx' => $val['content_idx']);

}

# 댓글 많은 뉴스 --> 뉴스 랭킹
$req_data = array();
$req_data['ranking_type']   = '2';
$req_data['content_type']   = '1';
$req_data['offset']         = 0;
$req_data['limit']          = 10;
$ci->load->model('web/m_ranking');
$arr_news_ranking    = $ci->m_ranking->ranking_join_news_list($req_data);





			$today_photo_count = count($arr_today_photo);
			$today_photo_page = ceil($today_photo_count/4);
			if($today_photo_count > 0) { ?>

                <div class="todayphoto">
					<h4>오늘의 포토</h4>
					<ul class="todayphoto_box">
				<? if($today_photo_count > 4) {?>
						<a href="javascript:change_today_photo_page(-1)"><span class="s_left"><img src="<?php echo imgSrc('/img/web/p_slide_left.png')?>"></span></a>
						<a href="javascript:change_today_photo_page(1)"><span class="s_right"><img src="<?php echo imgSrc('/img/web/p_slide_right.png')?>"></span></a>
				<? }?>
                <?  $i=1;
					foreach ($arr_today_photo as $val) {
                		$title_txt = mb_strimwidth($val['title'], '0', '40', '..', 'utf-8');

						$curr_page = ceil($i/4);
						$margin = '';$style_display='block';
						if($i%4==0)	$margin='margin-right:0px;';
						if($i > 4) 	$style_display='none';

				?>
                        <li class="today_photo_page<?=$curr_page?>" style="display:<?=$style_display?>;<?php echo $margin?>;cursor: pointer" onclick="location.href='/web/news/news_view/<?=$val['content_idx']?>'">
							<div style="width:171px; height:118px; background:url('<?php echo imgSrc($val['theme_img'])?>') no-repeat center; background-size:cover;"></div>
							<p class="card_title"><a href="/web/news/news_view/<?=$val['content_idx']?>"><?=$title_txt?></a></p>
						</li>

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

        <?  }?>

				<div class="mostreply">
					<div style="float:left; width:18%">
						<h4>댓글 많은 뉴스</h4>
						<span class="viewall" style="text-decoration:none !important"><a href="/web/news/ranking?ranking_type=2">전체보기 ></a></span>
					</div>


        <?  $i=1;
            foreach ($arr_news_ranking as $key=>$val) {
                $title_txt = mb_strimwidth($val['title'], '0', '30', '..', 'utf-8');

                if($i==1)   echo '<div style="float:left; width:40%; padding-right:2%">';
                if($i==6)   echo '<div style="float:left; width:40%;">';

        ?>
                    <div class="issue_box">
                        <span class="no"><?=$val['rank']?></span>
                        <span><a href="/web/news/news_view/<?=$val['content_idx']?>"><?=$title_txt?></a></span>
                    </div>

        <?
                if($i==5 || $i==10 || $i == count($arr_news_ranking)) echo '</div>';
                $i++;
            }?>

				</div>


<script>
var today_photo_curr_page = 1;
function change_today_photo_page(page){
	var total_page = "<?=$today_photo_page?>";
	var move_page = today_photo_curr_page + page;
	if(move_page > 0 && total_page >= move_page) {
		$(".today_photo_page"+move_page).show();
		$(".today_photo_page"+today_photo_curr_page).hide();
		today_photo_curr_page = move_page;
	}
}

</script>
