var target_div = '';
function getweather(target,rssurl){
	var t = new Date();
	target_div = target;
	xmlhttp = createXMLHttpRequest();
	if(xmlhttp){
		xmlhttp.onreadystatechange = check;
		xmlhttp.open("get",rssurl+'&t='+t,true);
		xmlhttp.send(null);
	}
}
function check(){
	var title0;
	var res = '';
	var img;
	var imgtitle;
	var imgurl;
	var imgwidht;
	var imgheight;
	var d;
	var xmlDoc;
	var LF = String.fromCharCode(10);
	if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
		xmlDoc = xmlhttp.responseXML;
		d = xmlDoc.getElementsByTagName("item");
		
		res = '<table id="weather"><tr><th colspan="3" class="title">お天気予報</th></tr>';
		for(i=1;i<=2;i++){
			title = d[i].getElementsByTagName("title")[0].firstChild.nodeValue + LF;
			title0 = title.split('-');
			res += '<tr><th>'+title0[3]+'</th>';

			imgtitle = d[i].getElementsByTagName("image")[0].getElementsByTagName("title")[0].firstChild.nodeValue + LF;
			imgurl = d[i].getElementsByTagName("image")[0].getElementsByTagName("url")[0].firstChild.nodeValue + LF;
			imgwidth = d[i].getElementsByTagName("image")[0].getElementsByTagName("width")[0].firstChild.nodeValue + LF;
			imgheight = d[i].getElementsByTagName("image")[0].getElementsByTagName("height")[0].firstChild.nodeValue + LF;
			img = '<img alt="'+imgtitle+'" src="'+imgurl+'"width="'+imgwidth+'" height="'+imgheight+'" />';
			res += '<td>'+img+'</td>';

			res += '<td>'+imgtitle+'</td></tr>';

//			result2 = d[i].getElementsByTagName("description")[0].firstChild.nodeValue + String.fromCharCode(10);

		}
		res += '</table>';
		document.getElementById(target_div).innerHTML = res;
	}
}
// XMLHttpオブジェクト作成
function createXMLHttpRequest(){
	var XMLhttpObject = null;
	try{
		XMLhttpObject = new XMLHttpRequest();
	}catch(e){
		try{
			XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				return null;
			}
		}
	}
	return XMLhttpObject;
}

