<?
# session
$SES_MEMBER_ID          = $this->session->userdata('C_Member_Id');
$SES_MEMBER_NAME        = $this->session->userdata('C_Member_Name');
$SES_MEMBER_NICNAME     = $this->session->userdata('C_Member_Nicname');
$SES_MEMBER_PROFILE     = $this->session->userdata('C_Member_Profile');
$SES_MEMBER_GROUPNAME   = $this->session->userdata('C_Member_Group_Name');
$SES_MEMBER_INTRO       = $this->session->userdata('C_Member_Intro');
if($SES_MEMBER_PROFILE == '')   $SES_MEMBER_PROFILE = '/img/web/img_profile_l.png';
if($SES_MEMBER_NICNAME == '')   $SES_MEMBER_NICNAME = $SES_MEMBER_NAME;

$weekday = array('일','월','화','수','목','금','토');


?>


<div class="contents">
	<div class="wrap" style="background:0;">

		<div class="c_left">
			 <div class="banner"><a href="http://www.cplace.co.kr/" target="http://www.cplace.co.kr/"><img src="/img/web/banner_745.jpg"></a>
			 <!-- PC_메인_헤드라인    
<ins class="adsbygoogle"
     style="display:inline-block;width:745px;height:121px"
     data-ad-client="ca-pub-7071495522658800"
     data-ad-slot="8751180656"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({});
</script> --> 
			</div>
			<div class="cont_box" id="cross_weather" style="position: absolute;z-index: 9995;display: none">
				<?

			$now_date = date("m.d");
			$week_date = date('w');
			$weather_date_txt = $now_date.'('.$weekday[$week_date].')';

		?>
				<span class="tt">영적기상도 </span><span class="date"> <?=$weather_date_txt?></span>
				<span class="box_related">관련뉴스</span>
			<ul>
				<?

			foreach ($arr_weather as $val) {
				$title = mb_strimwidth($val['title'], '0', '40', '..', 'utf-8');

		?>
				<li style="width:745px">
					<span class="country"><?=$val['continent']?></span>
					<span><?=$val['country']?><span class="weather"><img src="<?=$val['weather_icon']?>" width="22"></span> <?=$val['weather_content']?></span>
					<span style="margin-right:20px;" class="related_news"><a href="/web/news/news_view/<?=$val['relation_article_idx']?>"><?=$title?></a></span>
				</li>
<?	}?>
		  	</ul>
			</div><!--//cont_box-->

			<div class="art_box" style="margin: 16px 0;">

			<? 	if(isset($arr_headline_news[1])==true) {
					$title 			= mb_strimwidth($arr_headline_news[1]['title'], '0', '38', '..', 'utf-8');
					$sub_content 	= mb_strimwidth($arr_headline_news[1]['sub_content'], '0', '110', '..', 'utf-8');
			?>
				<div class="art_img" onclick="location.href='/web/news/news_view/<?=$arr_headline_news[1]['content_idx']?>'" style="cursor:pointer;">
					<span class="shadow"></span>
					<a href="/web/news/news_view/<?=$arr_headline_news[1]['content_idx']?>">
					<div style="width:365px; height:230px; background:url('<?=$arr_headline_news[1]['theme_img']?>') no-repeat center; background-size:cover;"></div>
					<div class="art_t_box">
						<p class="art_p_tit"><a href="/web/news/news_view/<?=$arr_headline_news[1]['content_idx']?>"><?=$title?></a></p>
						<p class="art_p_txt"><a href="/web/news/news_view/<?=$arr_headline_news[1]['content_idx']?>"><?=$sub_content?></a></p>
					</div></a>
				</div><!--//art_img-->
			<?	}?>


				<ul class="art_list">
			<? for($i=2;$i<=8;$i++) {
					if(isset($arr_headline_news[$i])==true){
						$title = mb_strimwidth($arr_headline_news[$i]['title'], '0', '48', '..', 'utf-8');
			?>

					<li><a href="/web/news/news_view/<?=$arr_headline_news[$i]['content_idx']?>"><?=$title?></a></li>
			<?		}
				}
			?>
				</ul>
			</div><!--//art_box-->


			<div class="cont_box2">
				<?
					$press_count 	= count($arr_press);
					$press_page 	= ceil($press_count/16);

					$cateogry_count = count($arr_company);
					$cateogry_page	= ceil($cateogry_count/16);

				?>
				<div id="press">
					<div class="company_top">
						<span class="cate">
						<span><a href="javascript:change_is_direct_type('press')" class="current">언론</a></span>
						<span class="bar"><img src="/img/web/news_bar.gif" alt="" style="padding: 0 5px;margin-top: 14px;"></span>
						<span><a href="javascript:change_is_direct_type('category')">카테고리별</a></span>
						<span class="c_arrow">
							<span><a href="javascript:change_press_page(-1);"><img src="/img/web/news_arrow_l.gif"></a></span>
							<span><a href="javascript:change_press_page(+1);"><img src="/img/web/news_arrow_r.gif"></a></span>
						</span>
					</div>
				<?

					$i=1;
					foreach($arr_press as $val) {

						$curr_page = ceil($i/16);

						if($i==1) 		echo '<div id="company_page1"><ul class="company_list">';
						if($i%9==0) 	echo '<ul class="company_list" style="border-bottom:0 !important">';
						if($i%17==0) 	echo '<div id="company_page'.$curr_page.'" style="display:none"><ul class="company_list">';

				?>
						<li><a href="<?=$val['homepage']?>" target="_blank"><img src="<?=$val['logo_img']?>" style="max-width:75px" class="ct"></a></li>
				<?
						if($i%8==0 || $press_count ==$i) echo '</ul>';
						if($i%16==0 || $press_count ==$i) echo '</div>';
						$i++;
					}
				?>
				</div>

				<div id="category" style="display:none">
					<div class="company_top">
						<span class="cate">
						<span><a href="javascript:change_is_direct_type('press')">언론</a></span>
						<span class="bar"><img src="/img/web/news_bar.gif" alt="" style="padding: 0 5px;margin-top: 14px;"></span>
						<span><a href="javascript:change_is_direct_type('category')" class="current">카테고리별</a></span>
						<span class="c_arrow">
							<span><a href="javascript:change_company_page(-1);"><img src="/img/web/news_arrow_l.gif"></a></span>
							<span><a href="javascript:change_company_page(+1);"><img src="/img/web/news_arrow_r.gif"></a></span>
						</span>
					</div>
				<?

					$i=1;
					foreach($arr_company as $val) {

						$curr_page = ceil($i/16);

						if($i==1) 		echo '<div id="company_page1"><ul class="company_list">';
						if($i%9==0) 	echo '<ul class="company_list" style="border-bottom:0 !important">';
						if($i%17==0) 	echo '<div id="company_page'.$curr_page.'" style="display:none"><ul class="company_list">';

				?>
						<li><a href="<?=$val['homepage']?>" target="_blank"><img src="<?=$val['logo_img']?>" style="max-width:75px" class="ct"></a></li>
				<?
						if($i%8==0 	|| $cateogry_count ==$i) echo '</ul>';
						if($i%16==0 || $cateogry_count ==$i) echo '</div>';
						$i++;
					}
				?>
				</div>

			</div>	<!-- // cont_box2 -->

			<? require_once(APPPATH."views/web/comm/weather_column_bar_inc.php"); ?>



			<div class="cardnews">
				<ul class="card_box">
			<? for($i=1;$i<=4;$i++) {
					if(isset($arr_life_home[$i])==true){
						$title_length = '20';
						if($arr_life_home[$i]['sub_title'] == '')	$title_length = '40';
						$title_txt = mb_strimwidth($arr_life_home[$i]['title'], '0', $title_length, '..', 'utf-8');
			?>

				<li>
					<div onclick="location.href='/web/life/life_view/<?=$arr_life_home[$i]['content_idx']?>'" style="cursor:pointer;width:171px; height:118px; border:1px solid #ccc;background:url('<?=$arr_life_home[$i]['theme_img']?>') no-repeat center; background-size:cover;"></div>
					<p class="card_title"><a href="/web/life/life_view/<?=$arr_life_home[$i]['content_idx']?>"><?=$title_txt?></a></p>
					<p class="card_txt"><?=$arr_life_home[$i]['sub_title']?></p>
				</li>
			<?
					} else  {
						echo '<li></li>';
					}

				}
			?>
				</ul>
				<ul class="card_box">
			<? for($i=5;$i<=6;$i++) {
					if(isset($arr_life_home[$i])==true){
						$title_length = '20';
						if($arr_life_home[$i]['sub_title'] == '')	$title_length = '40';
						$title_txt = mb_strimwidth($arr_life_home[$i]['title'], '0', $title_length, '..', 'utf-8');
			?>
					<li>
						<div onclick="location.href='/web/life/life_view/<?=$arr_life_home[$i]['content_idx']?>'" style="cursor:pointer;width:171px; height:118px; border:1px solid #ccc;background:url('<?=$arr_life_home[$i]['theme_img']?>') no-repeat center; background-size:cover;"></div>
						<p class="card_title"><a href="/web/life/life_view/<?=$arr_life_home[$i]['content_idx']?>"><?=$title_txt?></a></p>
						<p class="card_txt"><?=$arr_life_home[$i]['sub_title']?></p>
					</li>
				<?
					} else {
						echo '<li></li>';
					}
				}?>

				<? 	if(count($arr_card_news) > 0) {
						$content_type = $arr_card_news[0]['content_type'];
						switch ($content_type) {
							case '1':	$view_url = '/web/news/news_view/'.$arr_card_news[0]['content_idx'];
										break;
							case '2': 	$view_url = '/web/news/column_view/'.$arr_card_news[0]['content_idx'];
										break;
							case '3': 	$view_url = '/web/life/life_view/'.$arr_card_news[0]['content_idx'];
										break;
						}

				?>
					<!-- 카드 뉴스  -->
					<li class="card_main" style="z-index: 9995;cursor: pointer" onclick="location.href='<?=$view_url?>'">
						<span class="shadow"></span>
						<a href="<?=$view_url?>">
						<img src="<?=$arr_card_news[0]['main_img']?>">
						<p class="card_main_title">카<span>드뉴</span>스</p>
						<p class="card_main_txt"><a href="<?=$view_url?>"><?=$arr_card_news[0]['title']?></p></a></a>
					</li>
					<!--// 카드 뉴스  -->
				<?	}?>

				</ul>
				<ul class="card_box">
			<? for($i=7;$i<=10;$i++) {
					if(isset($arr_life_home[$i])==true){
						$title_length = '20';
						if($arr_life_home[$i]['sub_title'] == '')	$title_length = '40';
						$title_txt = mb_strimwidth($arr_life_home[$i]['title'], '0', $title_length, '..', 'utf-8');
			?>
					<li>
						<div onclick="location.href='/web/life/life_view/<?=$arr_life_home[$i]['content_idx']?>'" style="cursor:pointer;width:171px; height:118px; border:1px solid #ccc;background:url('<?=$arr_life_home[$i]['theme_img']?>') no-repeat center; background-size:cover;"></div>
						<p class="card_title"><a href="/web/life/life_view/<?=$arr_life_home[$i]['content_idx']?>"><?=$title_txt?></a></p>
						<p class="card_txt"><?=$arr_life_home[$i]['sub_title']?></p>
					</li>
			<?
					} else {
						echo '<li></li>';
					}
				}
			?>

				</ul>
			</div>
		</div><!--//c_left-->
		<div class="c_right">

	<? 	if($SES_MEMBER_ID=='') {?>

			<div class="login">
				<fieldset>
					<div class="input_box">
						<input type="text" name="main_login_member_id" id="main_login_member_id" class="int" placeholder="아이디">
					</div>
					<div class="input_box">
						<input type="password" name="main_login_member_pwd" id="main_login_member_pwd" class="int" placeholder="비밀번호" onkeypress="if( event.keyCode==13 ){main_login_proc();}">
					</div>
					<span class="btn_login"><input type="button" title="로그인" value="로그인" onclick="main_login_proc();"></span>
				</fieldset>
				<div class="chk_id_login">
					<input type="checkbox" name="main_save_login" id="main_save_login" value="Y" style="margin-right:5px;float:left"><label for="main_save_login">로그인 상태 유지</label>
					<span style="float:right;"><a href="javascript:commonLayerOpen('member_join1_layer');">회원가입</a><span><img src="/img/web/mypage_bar.gif" alt="" style="padding:0 3px; margin-top:3px;"></span><a href="javascript:commonLayerOpen('find_id_layer');">아이디</a>/ <a href="javascript:commonLayerOpen('find_pwd_layer');">비밀번호 찾기</a></span>
				</div>
			</div><!--login-->


	<?	} else { ?>
			<div class="login">
				<div class="mypage_opened_box">
					<div class="mypage_opened_info2">
						<div class="profile2">
							<span class="profile_l"><a href="javascript:commonLayerOpen('passwd_check_layer')"><img src="<?=$SES_MEMBER_PROFILE?>" width="47"></a></span>
							<span class="carmera"><img src="/img/web/img_camera.png"></span>
						</div>
						<div class="profile_detail" >
							<span class="name"><a href="javascript:commonLayerOpen('passwd_check_layer');"><?=$SES_MEMBER_NICNAME?></a></span> 님
							<div style="padding-top:7px; color:#000" ><span class="beachblue beauchblue_underline"><a href="javascript:commonLayerOpen('passwd_check_layer')">내정보</a></span><span class="grey"></span> <?=$SES_MEMBER_GROUPNAME?></div>
						</div>
						<div class="logout">
							<span class="btn"><a href="/web/member/logout_proc">로그아웃</a></span>
						</div>
					</div>
					<ul class="mypage_menu2">
					 <li><a href="/web/cs/notice">알림</a></li>
					 <li><a href="javascript:change_toggle('delivery_layer')">배달함 </a></li>
					 <li><a href="javascript:user_comment('<?=$SES_MEMBER_ID?>');">내댓글</a></li>
					 <li> <a href="/web/mypage/bookmark">북마크</a></li>
					 <li> <a href="/m/" target="_blank">모바일 보기</a></li>
					</ul>
				</div>
			</div>

	<?	}?>


			<div class="banner"><a href="http://www.chongsin.kr/index.php#&panel1-1" target="http://www.chongsin.kr/index.php#&panel1-1"><img src="/img/web/banner_300_2.jpg"></a> 
<!-- PC_메인_우측상단   
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:103px"
     data-ad-client="ca-pub-7071495522658800"
     data-ad-slot="7294628759"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script> -->
		</div>

			<? if(count($arr_today_word)>0){ ?>
			<div class="dailybread">
				<div class="db_top">
					<span class="date"><?=date("m.d")?>(<?=$weekday[date("w")]?>)</span>
					<span class="box_title">오늘의 말씀</span>
				</div>

				<div class="message">
					<?=$arr_today_word['word']?>
				</div>
				<span class="verse"> - <?=$arr_today_word['title']?> -</span>


			</div><!--//dailybread-->
			<?	} ?>

			<? if(count($arr_daily_cutie) > 0) {?>
				<div class="photo_news" style="z-index: 9995;cursor: pointer" onclick="location.href='/web/life/life_view/<?=$arr_daily_cutie[1]['content_idx']?>'">
					<span class="shadow"></span>
					<div style="width:300px; height:291px; background:url('<?=$arr_daily_cutie[1]['theme_img']?>') no-repeat center; background-size:cover;"></div>
					<p class="card_main_title">데<span>일리큐</span>티</p>
					<p class="card_main_txt"><a href="/web/life/life_view/<?=$arr_daily_cutie[1]['content_idx']?>"><?=$arr_daily_cutie[1]['title']?></a> </p>
				</div>
			<? }?>

			<div class="banner"><a href="http://intercp.net/02_01.jsp" target="http://intercp.net/02_01.jsp"><img src="/img/web/banner_300.jpg"></a>
<!-- PC_메인_우측하단  
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:600px"
     data-ad-client="ca-pub-7071495522658800"
     data-ad-slot="6752112391"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({});
</script> --> 
		</div>
		</div><!--//c_right-->
	</div><!--//wrap-->
</div><!--//contents-->


<script>
$( document ).ready(function() {
	$("#cross_weather").show();
	$('#cross_weather').vTicker();
});






var press_curr_page = 1;
function change_press_page(page){
	var total_page = "<?=$press_page?>";
	var move_page = press_curr_page + page;
	if(move_page > 0 && total_page >= move_page) {
		$("#company_page"+move_page).show();
		$("#company_page"+press_curr_page).hide();
		press_curr_page = move_page;
	}
}
var company_curr_page = 1;
function change_company_page(page){
	var total_page = "<?=$cateogry_count?>";
	var move_page = company_curr_page + page;
	if(move_page > 0 && total_page >= move_page) {
		$("#company_page"+move_page).show();
		$("#company_page"+company_curr_page).hide();
		company_curr_page = move_page;
	}
}

function change_is_direct_type(id) {
	$("#press").hide();
	$("#category").hide();
	$("#"+id).show();
}



// 로그인
function main_login_proc(){
    if($("#main_login_member_id").val()=="") {
        alert("아이디를 입력해주세요.");
        return false;
    }
    if($("#main_login_member_pwd").val()=="") {
        alert("아이디를 입력해주세요.");
        return false;
    }

	var save_login = 'N';
	if($('input:checkbox[id="main_save_login"]').is(":checked") == true){
		save_login = $('input:checkbox[id="main_save_login"]').val()
	}

    var form_data = {
        "member_id"		: $("#main_login_member_id").val(),
        "member_pwd"    : $("#main_login_member_pwd").val(),
        "save_login"    : save_login
    };
    $.ajax({
        url: '/web/member/login_proc',
        async: false,
        type: 'POST',
        dataType: 'JSON',
        data: form_data,
        success: function (rtnJson) {
            if (rtnJson.code == "0000") {
            	if(rtnJson.msg!=''){
                    alert(rtnJson.msg);
                }
                location.href="/";
            } else {
                alert(rtnJson.msg);
                return false;
            }
        },
        error: function (rtnJson) {
            alert('로그인에 실패했습니다.');
            return false;
        }
    });
}



// This is called with the results from from FB.getLoginStatus().
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);
        }
    });
}


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




</script>