$(function(){
	// livedoor お天気Webサービス
	// formのオプション指定
	var option = {
		url     : "data/app/lwws.php",
		type    : "GET",
		dataType: "text",
		success : function(text, status) {
			var xotree = new XML.ObjTree();
			var tree = xotree.parseXML(text);
			$("#title").html(tree.lwws.title);
			$("#telop").html(tree.lwws.telop);
			$("#image img").attr("src"   , tree.lwws.image.url);
			$("#image img").attr("width" , tree.lwws.image.width);
			$("#image img").attr("height", tree.lwws.image.height);
			$("#image img").attr("alt"   , tree.lwws.telop);
			if(tree.lwws.temperature.min.celsius == null) {
				$("#min").html("0");
			} else {
				$("#min").html(tree.lwws.temperature.min.celsius);
			}
			if(tree.lwws.temperature.max.celsius == null) {
				$("#max").html("0");
			} else {
				$("#max").html(tree.lwws.temperature.max.celsius);
			}
		}
	};
	// 最初のデータ取得
	$("#weatherform").ajaxSubmit(option);
	// cityを変更したとき
	$("select[name='city']").change(function(){
		$("#weatherform").ajaxSubmit(option);
	});
	// dayを変更したとき
	$("select[name='day']").change(function(){
		$("#weatherform").ajaxSubmit(option);
	});

});

