<?
if($result_code == '0000') {
    echo '0000|||||';
    $row_count = count($list);

    if($row_count > 0) {

        $max_rand_num = $limit-1;
        if($total_count < $limit)     $max_rand_num = $total_count-1;
        if(count($list) < $limit)     $max_rand_num = count($list);

        $relation_count = 8;
        if($total_count < 8)     $relation_count = $total_count-1;
        $row = 1;
        if($page > 1)   $row = $view_count +1;
        foreach($list as $i=>$val) {
            $idx        =$val['idx'];
            $main_img   =$val['main_img'];

            $info       = getimagesize('.'.$main_img);
            $img_width 	= $info[0];
            $img_height = $info[1];
            $img_mime   = $info[2];




            $title_text = 	$val['title'];
            if(isset($val['category_name'])==true)	$title_text.= ' - '.$val['category_name'];

            $img_type = array('1'=>'GIF', '2'=>'JPG','3'=>'PNG','4'=>'PSD','5'=>'BMP','6'=>'TIFF','7'=>'TIFF','8'=>'JPC','9'=>'JP2','10'=>'JPX','11'=>'JB2','12'=>'SWC','13'=>'IFF','14'=>'WBMP','15'=>'XBM');


            switch ($val['content_type']) {
                case '1': $img_view_url = '/m/news/news_view/'.$val['idx'];	$content_name='뉴스'; $content_main_url='/web/news'; break;
                case '2': $img_view_url = '/m/news/column_view/'.$val['idx'];	$content_name='칼럼'; $content_main_url='/web/news/column'; break;
                case '3': $img_view_url = '/m/life/life_view/'.$val['idx'];	$content_name='라이프'; $content_main_url='/web/life'; break;
            }


//            $req_data = array();
//            $req_data['search_type']            = 'main_search';
//            $req_data['search_keyword']         = $search_keyword_tmp;
//            $req_data['row_num']                = $val['row_num'];
//
//            $this->load->model('web/m_vw_content');
//            $arr_next   = $this->m_vw_content->vw_content_next_select($req_data);
//            $arr_prev   = $this->m_vw_content->vw_content_prev_select($req_data);



//            $req_data = array();
//            $req_data['search_type']            = 'main_search';
//            $req_data['search_keyword']         = $search_keyword_tmp;
//            $req_data['offset']                 = 0;
//            $req_data['limit']                  = 8;
//            $req_data['idx']                    = $idx;
//            $this->load->model('web/m_vw_content');
//            $arr_relation_img   = $this->m_vw_content->vw_content_where_not_idx_list($req_data);




			$cnt = ($page-1) * 100 + $i;
//			$arr = array();
//			$arr[] = array("src"=>$main_img,"href"=>$img_view_url,"text"=>$title_text);
			echo "<div style='display:none;' class='thumb_".$cnt." src'>".$main_img."</div>";
			echo "<div style='display:none;' class='thumb_".$cnt." href'>".$img_view_url."</div>";
			echo "<div style='display:none;' class='thumb_".$cnt." text'>".$title_text."</div>";

?>


				<a href="#somelink" class="thumb thumb-img" style="background-image: url(<?=$main_img?>)"  onclick="show_bigsize(<?=$cnt?>)">
					<img src="<?=$main_img?>" title="<?=$title_text?>" alt="<?=$title_text?>">


					<?
					for ($z=0;$z<$relation_count;$z++) {
						$key = rand(0, $max_rand_num);
						if(isset($list[$key]) == true) {


							$val2 = $list[$key];
							switch ($val2['content_type']) {
								case '1': $img_view_url2 = '/m/news/news_view/'.$val2['idx'];     break;
								case '2': $img_view_url2 = '/m/news/column_view/'.$val2['idx'];	break;
								case '3': $img_view_url2 = '/m/life/life_view/'.$val2['idx'];	     break;
							}
							$alt_text2 =     $val2['title'];
							if(isset($val2['category_name'])==true)	$alt_text2.= ' - '.$val2['category_name'];

							echo "<div style='display:none;' class='thumb_".$cnt." src' id=\"thumb_".$cnt."\">".$val2['main_img']."</div>";
							echo "<div style='display:none;' class='thumb_".$cnt." href'>".$img_view_url2."</div>";
							echo "<div style='display:none;' class='thumb_".$cnt." text'>".$alt_text2."</div>";

						}
					}



					?>

				</a>


<?
            $row++;
		}
    }


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

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

}
?>

