<?
include_once("_common.php");

//-- "":주요누스, p정치, b경제, y사회, l문화, w국제, t과학, e연예, s스포츠
$news_topic		= array("", "p", "b", "s", "e", "y", "l", "w", "t");
$news_section	= array("구글뉴스", "정치", "경제", "스포츠", "연예", "사회", "문화/생활", "국제", "과학");
?>

<link rel="stylesheet" type="text/css" href="<?=$service_path?>/style.css">
<div id="zm_googlenews_body">
	<div id="zm_googlenews_subject">
		<div id="zm_googlenews_sbj_0" class="zm_googlenews_sbj zm_googlenews_sbj_crrnt" onClick="load_news('<?=$news_topic[0]?>'); zm_googlenews_section_toggle('0'); zm_googlenews_extend_toggle('0');"><a><?=$news_section[0]?></a></div>
		<div style="padding:0 0 10px 10px;">
			<span id="zm_googlenews_ext_0" class="zm_googlenews_extend zm_googlenews_extend_crrnt" onClick="zm_googlenews_extend_toggle('0'); load_news('');" title="뉴스">●</span>
			<span id="zm_googlenews_ext_5" class="zm_googlenews_extend" onclick="load_news('y'); zm_googlenews_extend_toggle('5');" title="사회">●</span>
			<span id="zm_googlenews_ext_6" class="zm_googlenews_extend" onclick="load_news('l'); zm_googlenews_extend_toggle('6');" title="문화/생활">●</span>
			<span id="zm_googlenews_ext_7" class="zm_googlenews_extend" onclick="load_news('w'); zm_googlenews_extend_toggle('7');" title="국제">●</span>
			<span id="zm_googlenews_ext_8" class="zm_googlenews_extend" onclick="load_news('t'); zm_googlenews_extend_toggle('8');" title="과학">●</span>
		</div>
<?	for($i = 1; $i < 5; $i++) : ?>
		<div id="zm_googlenews_sbj_<?=$i?>" class="zm_googlenews_sbj <?=($i < 1) ? 'zm_googlenews_sbj_crrnt' : 'zm_googlenews_sbj_other'?>" onClick="load_news('<?=$news_topic[$i]?>'); zm_googlenews_section_toggle('<?=$i?>')"><a><?=$news_section[$i]?></a></div>
<? endfor; ?>
	</div>
	<div id="zm_googlenews_list_box"><img src="<?=$service_path?>/img/loading.gif"></div> <!-- zm_googlenews_section_box -->
</div>

<script language="javascript">
function zm_googlenews_extend_toggle(i) {
	var ext_point	= "zm_googlenews_ext_" + i;
	$(".zm_googlenews_extend").removeClass("zm_googlenews_extend_crrnt");
	$("#"+ext_point).addClass("zm_googlenews_extend_crrnt");
}

function zm_googlenews_section_toggle(i) {
	$(".zm_googlenews_extend").removeClass("zm_googlenews_extend_crrnt");
	$(".zm_googlenews_sbj").removeClass("zm_googlenews_sbj_crrnt");
	$(".zm_googlenews_sbj").addClass("zm_googlenews_sbj_other");
	var latest_subject	= "zm_googlenews_sbj_" + i;
	$("#"+latest_subject).removeClass("zm_googlenews_sbj_other");
	$("#"+latest_subject).addClass("zm_googlenews_sbj_crrnt");
}

function load_news(t){
	var img_loading	= "<img src='<?=$service_path?>/img/loading.gif'>";
	$("#zm_googlenews_list_box").html(img_loading);

	$.ajax({
		type: "post",
		url: "<?=$service_path?>/google_news_loading.php?topic="+t,
		success: function(result){
			$("#zm_googlenews_list_box").html(result);
		}
	});
}

$(document).ready(function(){
	load_news("");	//-- 주요뉴스 읽어오기
});
</script>