');
}
weather.changeWeatherCity = function (val){
if (val == "" || val == "全部城市"){
alert("请您选择城市!");
document.getElementById('weatherCity').focus();
return false;
}else{
weather.city = val;
weather.city_ok = weather.city.replace(/市/g,"");
var _doc = document.getElementsByTagName('head')[0];
var js = document.createElement('script');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', 'http://php.weather.sina.com.cn/js.php?city='+weather.city_ok);
_doc.appendChild(js);
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1){//IE6、IE7
js.onreadystatechange = function () {
if (js.readyState == 'loaded' || js.readyState == 'complete') {
weather.writeWeatherReport();
weather.setWeatherCityTocookie('weatherCity', weather.city, 365);
jQuery('.wthpop').hide();
}
}
}else{//Is Firefox2、Firefox3、Safari3.1+、Opera9.6+
js.onload = function () {
weather.writeWeatherReport();
weather.setWeatherCityTocookie('weatherCity', weather.city, 365);
jQuery('.wthpop').hide();
}
}
}
}
weather.setWeatherCityTocookie = function (name, value, days){
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}else{
expires = "";
}
document.cookie = name + "=" + encodeURI(value) + expires + "; path=/";
}
weather.getWeatherCityFromcookie = function (name){
//alert(document.cookie);
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i=0; i var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return decodeURI(c.substring(nameEQ.length, c.length)); } return false; } weather.city = weather.getWeatherCityFromcookie('weatherCity'); weather.getCityWeather();