<?
include("_common.php");
/*
기상청에서 제공하는 날씨 api를 이용한 날씨 위젯
기상청 XML 제공 페이지 : http://www.kma.go.kr/weather/lifenindustry/sevice_rss.jsp
*/

include("weather.load.php");
?>
<style type="text/css">
#zm_kma_weather_body	{ position:absolute; width:98px; height:100px; overflow:hidden; z-index:99; text-align:left; }
#zm_kma_weather_box		{ position:absolute; width:98px; cursor:pointer; }
#zm_kma_weather_box .zm_kma_weather_item	{ height:100px; text-align:center; }
#zm_kma_weather_box .w_icon		{ }
#zm_kma_weather_box .w_temp		{ padding:3px; color:#575E69; }
#zm_kma_weather_box .w_temp1	{ font-size:20px; font-weight:bold; font-family:Arial; }
#zm_kma_weather_box .w_temp2	{ font-size:14px; font-family:나눔고딕; }
#zm_kma_weather_box .w_txt		{ color:#575E69; font-size:11px; font-family:나눔고딕; }
</style>

<div id="zm_kma_weather_body">
<div id="zm_kma_weather_box">
<? for($i = 0; $i < count($w_data); $i++) : ?>
	<div class="zm_kma_weather_item">
		<div class="w_icon"><img src="<?=$w_data[$i][ICON]?>"></div>
		<div class="w_temp"><span class="w_temp1"><?=$w_data[$i][TEMP]?></span><span class="w_temp2">℃</span></div>
		<div class="w_txt"><?=$w_data[$i][LOCA]?> <?=$w_data[$i][TXT]?></div>
	</div>
<? endfor; ?>
</div>
</div>

<script language="javascript">
var wscroll_div_height = $("#zm_kma_weather_box").height();
var wscroll_count	= 0;
var wscroll_height	= 100;		/*한 번에 스크롤 할 높이*/

wscroll_div_pos = $("#zm_kma_weather_box").position();
$("#zm_kma_weather_box").css("top", wscroll_div_pos.top+"px");
function zm_kma_weather_scroll(){
	if(wscroll_div_height < wscroll_count) {
		$("#zm_kma_weather_box").css("top", wscroll_height+"px");
		wscroll_count = 0;
	}

	wscroll_div_pos = $("#zm_kma_weather_box").position();
	var new_wstop	= wscroll_div_pos.top - 1;

	$("#zm_kma_weather_box").css("top", new_wstop+"px");
	wscroll_count++;

	if(wscroll_count % wscroll_height) {
		wscrollTimmer = setTimeout("zm_kma_weather_scroll()", 5);
	}else{
		wscrollTimmer = setTimeout("zm_kma_weather_scroll()", 3000);
	}
}

function zm_kma_weather_scroll_stop() {
	$("#zm_kma_weather_box").css("top", "0px");

    clearTimeout(wscrollTimmer);
}

function zm_kma_weather_scroll_again() {
	$("#zm_kma_weather_box").css("top", wscroll_height+"px");
	wscrollTimmer = setTimeout("zm_kma_weather_scroll()", 10);
}

setTimeout("zm_kma_weather_scroll()", 1)
zm_kma_weather_box.onclick = function() {
	window.open("http://www.kma.go.kr/weather/main.jsp", "weather");
}
</script>