﻿// Initialize
function ajaxInitRV(){
	try
	{
		reqRV = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			reqRV = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			reqRV = null;
		}
	}

	if(!reqRV && typeof XMLHttpRequest!="undefined")
	{
		reqRV=new XMLHttpRequest();
	}
}

//获得天气预报资料
function getWeather(){
	var url = "weather.asp";
	var ajaxRV = null;
	var tempStr = null;
	ajaxInitRV();
	if(reqRV != null)
	{
		reqRV.onreadystatechange = function() {
			if (reqRV.readyState == 4) {
				if (reqRV.status == 200) {
					ajaxRV = reqRV.responseText.split(",");
					tempStr = "<table width=\"100%\" border=\"0\">";
					tempStr += "<tr><td width=\"50\">&nbsp;&nbsp;&nbsp;<b>"+ajaxRV[1]+"</b></td><td>&nbsp;&nbsp;&nbsp;"+ajaxRV[2]+"</td></tr>";
					tempStr += "<tr><td width=\"50\"><img src=\"images/weather/tem1.gif\" style=\"margin:0px;\"></td><td>&nbsp;&nbsp;&nbsp;"+ajaxRV[3]+"</td></tr>";
					tempStr += "<tr><td width=\"50\"><img src=\"images/weather/tem2.gif\" style=\"margin:0px;\"></td><td>&nbsp;&nbsp;&nbsp;"+ajaxRV[4]+"</td></tr>";
					tempStr += "<tr><td width=\"50\"><img src=\"images/weather/tem3.gif\" style=\"margin:0px;\"></td><td>&nbsp;&nbsp;&nbsp;"+ajaxRV[5]+"</td></tr>";
					tempStr += "<tr><td width=\"50\"><img src=\"images/weather/tem5.gif\" style=\"margin:0px;\"></td><td>&nbsp;&nbsp;&nbsp;"+ajaxRV[6]+"</td></tr>";
					tempStr += "</table>"
					document.getElementById("dhWeather").innerHTML = tempStr
				}else{
					document.getElementById("dhWeather").innerHTML = "载入失败， <a href=\"javascript:void(getWeather(););\">重试</a> ？"
				}
			}
		}
		reqRV.open("GET", encodeURI(url), true);
        	reqRV.send();
	}
}


