//今天&明天天气预报

function G(A){return document.getElementById(A)}function C(A){return document.createElement(A)}function GN(A){return document.getElementsByName(A)}function trim(A){return A.replace(/(^\s*)|(\s*$)/g,"")}function trimPun(A){return A.replace(/(\'+)|(\"+)/g,"")}var isIE=navigator.userAgent.indexOf("MSIE")!=-1&&!window.opera;var isWebKit=(navigator.userAgent.indexOf("AppleWebKit/")>-1);var isGecko=(navigator.userAgent.indexOf("Gecko")>-1)&&(navigator.userAgent.indexOf("KHTML")==-1);var isOpera=navigator.userAgent.indexOf("Opera")!=-1;try{var isMaxthon=!!external.max_version}catch(e){}Function.prototype.bind=function(){var E=[];for(var F=0,B=arguments.length;F<B;F++){E.push(arguments[F])}var A=this,D=E[0];return function(){return A.apply(D,E)}};Object.extend=function(A,D){for(var B in D){A[B]=D[B]}return A};var days=36500;var expdate=new Date();expdate.setTime(expdate.getTime()+(86400*1000*days));var cookieEnabled=(navigator.cookieEnabled)?true:false;function getCookieVal(B){var A=document.cookie.indexOf(";",B);if(A==-1){A=document.cookie.length}return unescape(document.cookie.substring(B,A))}function deleteCookie(A,D,B){if(getCookie(A)){document.cookie=A+"="+((D)?"; path="+D:"")+((B)?"; domain="+B:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}}function getCookie(E){var B=E+"=";var H=B.length;var A=document.cookie.length;var F=0;while(F<A){var D=F+H;if(document.cookie.substring(F,D)==B){return getCookieVal(D)}F=document.cookie.indexOf(" ",F)+1;if(F==0){break}}return null}function setCookie(D,F){if(cookieEnabled==false){alert("没有Cookie存在!");return false}var A=setCookie.arguments;var I=setCookie.arguments.length;var B=(2<I)?A[2]:null;var H=(3<I)?A[3]:null;var E=(4<I)?A[4]:null;document.cookie=D+"="+escape(F)+";expires="+B.toGMTString()+";path="+H+";domain="+E}Function.prototype.bind=function(){var E=[];for(var F=0,B=arguments.length;F<B;F++){E.push(arguments[F])}var A=this,D=E[0];return function(){return A.apply(D,E)}};function setStyle(B,A){var D=document.styleSheets[0];if(D.addRule){D.addRule(B,A)}else{if(D.insertRule){D.insertRule(B+" { "+A+" }",D.cssRules.length)}}}String.prototype.replaceS=function(){if(arguments.length==0){return this}for(var B=0,A=arguments.length,D=this;B<A;B++){D=D.replace(new RegExp("#\\{"+(B+1)+"\\}#"),arguments[B])}return D};function regEvent(D,A,B){if(isIE){D.attachEvent(A,B)}else{D.addEventListener(A.replace(/^on/,""),B,false)}}function addEvent(D,A,B){if(isIE){D.attachEvent("on"+A,B)}else{D.addEventListener(A,B,false)}}function delEvent(D,B,A){if(!(D=G(D))){return false}B=B.replace(/^on/,"").toLowerCase();if(D.attachEvent){D.detachEvent("on"+eventName,D[B+A]);D[eventName+A]=null}else{D.removeEventListener(eventName,A,false)}}var gData=function(){var D={};function B(F){if(D[F]){return D[F]}return null}function E(F,H){D[F]=H}function A(F){delete D[F]}return{get:B,set:E,del:A}}();

var XSAjax=(function(){function b(f){var d=[];if(!f){return""}for(var e in f){if(!f[e]){break}d.push(e+"="+encodeURIComponent(f[e]))}return d.join("&")}function c(d,e){var f="";if(!d){return""}if(!!e){f=e+"&"}f+="ra="+Math.random();if(-1<d.indexOf("?")){return d+"&"+f}return d+"?"+f}function a(f){if(!f||!f.url){return}if(f.onbeforesend&&typeof f.onbeforesend=="function"){f.onbeforesend()}var g="",e,d;g=b(f.json);d=c(f.url,g);e=document.createElement("SCRIPT");e.src=d;if(isIE){e.onreadystatechange=function(){if(e.readyState=="complete"||e.readyState=="loaded"){document.body.removeChild(e);if(f.onsuccess&&typeof f.onsuccess=="function"){f.onsuccess()}}}}else{e.onload=function(){document.body.removeChild(e);if(f.onsuccess&&typeof f.onsuccess=="function"){f.onsuccess()}}}document.body.appendChild(e)}return{send:a}})();(function(){var COOKIE_NAME="HAOFORECAST",COOKIE_PATH="/",COOKIE_DOMAIN=["haol23.cn","haol23.cn"],REQUEST_URL="http://search.hao123.com/weather/bin/forecast.php",EXPIRE_HOUR=3,MAXLEN=11,SHEZHI_URL="tianqi/";function initializeForecast(){if(!cookieEnabled){requestForecast(cityName);return}var fcCookie=getCookie(COOKIE_NAME);if(null==fcCookie){requestForecast();return}var valueArr=fcCookie.split("|");if(3!=valueArr.length){return}if(valueArr[0]==""){requestForecast();return}else{if(valueArr[1]==""){requestForecast(cityName);return}}for(var i=0,len=valueArr.length;i<len;i++){valueArr[i]=decodeURIComponent(valueArr[i])}var cityName=valueArr[0],lastModified=valueArr[1],fcStr=valueArr[2];if(!isLatest(lastModified)){requestForecast(cityName);return}try{var evalStr="var HaoForecast = "+fcStr;eval(evalStr)}catch(e){return}displayForecast(HaoForecast)}function isLatest(lastModified){var now=new Date(),timeSpan=1000*3600*EXPIRE_HOUR;if(now.getTime()-lastModified>timeSpan){return false}return true}function requestForecast(cityName){var reqOptions={url:REQUEST_URL,json:{city_name:cityName||""},onbeforesend:function(){}};XSAjax.send(reqOptions)}function truncate(str,max){if(!str){return""}if(!max){return str}return str.substr(0,max)}function serializeJSON(json){var retVal="";if(typeof json=="string"){retVal+='"'+unicode(json)+'"'}if(typeof json=="number"){retVal+=""+unicode(json)+""}if(typeof json=="object"&&json.length){retVal+="[";for(var i=0;i<json.length-1;i++){retVal+=serializeJSON(json[i])+","}retVal+=serializeJSON(json[i]);retVal+="]"}else{if(typeof json=="object"&&json.length==undefined){retVal+="{";for(var i in json){retVal+='"'+i+'":'+serializeJSON(json[i])+","}retVal=retVal.substr(0,retVal.length-1)+"}"}}return retVal}function unicode(str){var len=str.length,retStr="",tmpStr;if(str==undefined){return""}for(var i=0;i<len;i++){tmpStr=str.charCodeAt(i).toString(16);if(tmpStr.length==1){tmpStr="000"+tmpStr}if(tmpStr.length==2){tmpStr="00"+tmpStr}if(tmpStr.length==3){tmpStr="0"+tmpStr}retStr+="\\u"+tmpStr}return retStr}function displayForecast(forecast){if(!forecast){return}var tmpArr=[],dateStr="",fcObj;tmpArr.push('<strong>'+forecast.Name+":&nbsp;&nbsp;");fcObj=forecast.forecast[0];tmpArr.push(truncate(fcObj.Day,MAXLEN)+" ");tmpArr.push(fcObj.Tmax+"℃/"+fcObj.Tmin+"℃</strong>&nbsp;");G("Forecast").innerHTML=tmpArr.join("")}function updateForecast(forecast){if(!forecast){return}var now=new Date(),fcCookie=encodeURIComponent(forecast.Name)+"|"+encodeURIComponent(now.getTime())+"|"+encodeURIComponent(serializeJSON(forecast)),nextYear=new Date();nextYear.setFullYear(now.getFullYear()+1);displayForecast(forecast);for(var i=0,len=COOKIE_DOMAIN.length;i<len;i++){setCookie(COOKIE_NAME,fcCookie,nextYear,COOKIE_PATH,COOKIE_DOMAIN[i])}}function init(){initializeForecast();window.haoForecastCallback=updateForecast}if(isIE){window.attachEvent("onload",init)}else{window.addEventListener("load",init,false)}})();
