// 
function xload(xmlString){  
	var xdom = null;	
	if(document.implementation && document.implementation.createDocument){
		var parser = new DOMParser();		
		xdom = parser.parseFromString( xmlString , "text/xml");
		if (xdom.documentElement.nodeName == "parsererror") {
			alert('파싱 오류1');
			return null;
		} 
	}else if( window.ActiveXObject){
		xdom = new ActiveXObject("Microsoft.XMLDOM");
		xdom.async = "false";
		xdom.loadXML(xmlString);
	  //xdom.load( path );	    
    if (xdom.parseError.errorCode != 0) {
    	alert('파싱 오류2');
    	return null;
    	}        
	}  
	return xdom.documentElement;
}

/*

<forecast_information>
	<city data="Seongju-gun, Gyeongsangbuk-do"/>
	<postal_code data="Seongju"/>
	<latitude_e6 data=""/>
	<longitude_e6 data=""/>
	<forecast_date data="2009-09-19"/>
	<current_date_time data="2009-09-19 05:00:00 +0000"/>
	<unit_system data="SI"/>
</forecast_information>
<current_conditions>
	<condition data="흐림"/>
	<temp_f data="77"/>
	<temp_c data="25"/>
	<humidity data="습도: 44%"/>
	<icon data="/ig/images/weather/cloudy.gif"/>
	<wind_condition data="바람: 남풍, 21 km/h"/>
</current_conditions>
<forecast_conditions>
<day_of_week data="토"/>
<low data="15"/>
<high data="26"/>
<icon data="/ig/images/weather/sunny.gif"/>
<condition data="맑음"/>
</forecast_conditions>


*/
function weatherRender(xRoot){
		var dateX = xRoot.getElementsByTagName("forecast_information").item(0);	
		var itemList = xRoot.getElementsByTagName("forecast_conditions").item(0);	
		var forecast_date = dateX.getElementsByTagName("forecast_date").item(0).getAttribute("data");
		var day_of_week = itemList.getElementsByTagName("day_of_week").item(0).getAttribute("data");
		var condition = itemList.getElementsByTagName("condition").item(0).getAttribute("data");	
		
		if(forecast_date == null || forecast_date != ""){
			var temp_forecast_date = forecast_date.split("-");
			forecast_date = temp_forecast_date[1]+". "+temp_forecast_date[2];		
			$("#sjWeather").html("<strong>"+temp_forecast_date[1]+". "+ temp_forecast_date[2]+"</strong> <span class=\"week\">("+ day_of_week +")</span> " + condition );
		}	
}

/* 구글 날씨 */
function googleWeather(val)
{
	if(val != null && val != ""){
		var xDom =  xload(val);			 
		weatherRender(xDom);
	}
}

function nowWeather()
{	
	//http://www.google.com/ig/api?weather=Seongju&ie=utf-8&oe=utf-8&hl=ko
	//jQuery.get("http://www.google.com/ig/api?weather=Seongju&ie=utf-8&oe=utf-8&hl=ko" , {} , function(data){	
	jQuery.post("/portal/common/etc/googleWeather.jsp" , {} , function(data){		
		var temp = data;
		temp = temp.replace("\r","");
		temp = temp.replace("\n","");
		if(temp != null && temp != ""){
			var xDom =  xload(temp);	
			if(xDom != null) weatherRender(xDom);
		}
	}, "text");
}

function scac(val){
	alert(val);
	/*
	<h4><a href="http://www.scac.go.kr/html/play/detail.html?idx=253" title="음악극 로미오와 줄리엣" target="_blank"><img src="/portal/img/main/poster_img01.gif" alt="음악극 로미오와 줄리엣" width="203" height="140" /></a></h4>
    <ul class="hidden">
      <li>일시 : 2009년 9월 15일</li>
      <li>장소 : 성주문화회관</li>
    </ul>
    */	
}
