hao360.skin.blue={"previewImg":"","name":"\u84dd\u8272","iePreload":["images\/skin\/blue_bg_0616.png","images\/skin\/blue_s_bg.png"],"sort":"default","css":"a{color:#07519A;}.wrap-outer{background:#fff url(images\/skin\/blue_bg_0616.png) repeat-x 0 0\\9;background:linear-gradient(#eff8ff 0%,#fff 15%) no-repeat;background:-moz-linear-gradient(#eff8ff 0%,#fff 15%) no-repeat;background: -webkit-gradient(linear, 0 0, 0 15%, from(#eff8ff), to(#fff)) no-repeat;background:-o-linear-gradient(#eff8ff 0%, #fff 15%) no-repeat;}.tabs-box{background:url(images\/skin\/blue_s_bg.png) repeat-x 0 0\\9;background: -moz-linear-gradient(#fff 0%,#f1f9ff 100%) no-repeat;background: -webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#f1f9ff)) no-repeat;background:-o-linear-gradient(#fff 0%,#f1f9ff 100%) no-repeat;}a#logo{top:6px;background:url('images\/logo.png') no-repeat;_background-image: none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images\/logo.png', sizingMethod='image');}a{color:#07519A;}body a{_color:#07519A;}.cust-border-color,.channel li,.tabs li,.usage-tabs li,.pop-border,.mynav-line,.tipcon dl{border-color:#ace;}.tabs li{background-color:#eef7ff;}.tabs li.selected{background-color:#fff;}.side,.usage,.recom-area{background-color:#f3faff;}.channel li.hover{background-color:#d7eeff;}.usage-tabs li{background-color:#fff;}.usage-tabs li.selected{background-color:#f3faff;}.poptip p,.tipcon{background-color:#fff;}.tipcon dl.hover{background-color:#eef7ff;}.main{background-color:#fefefe;}.kuzhan-nav{background-color:#eef7ff;}.kuzhan-nav a{border-color:#ace;}#suggests a{background-color:#f9fcff;}#suggests a.hover{background-color:#a8d5fc}"};
hao360.skin.darkgreen={"previewImg":"","name":"\u6df1\u7eff","iePreload":["images\/skin\/darkgreen_bg.png","images\/skin\/darkgreen_s_bg.png"],"sort":"default","css":".wrap-outer{background:#fff url(images\/skin\/darkgreen_bg.png) repeat-x 0 0\\9;background:linear-gradient(#f9fff1 0%,#fff 15%) no-repeat;background:-moz-linear-gradient(#f9fff1 0%,#fff 15%) no-repeat;background: -webkit-gradient(linear, 0 0, 0 15%, from(#f9fff1), to(#fff)) no-repeat;background:-o-linear-gradient(#f9fff1 0%, #fff 15%) no-repeat;}.tabs-box{background:url(images\/skin\/darkgreen_s_bg.png) repeat-x 0 0\\9;background: -moz-linear-gradient(#fff 0%,#f4fbeb 100%) no-repeat;background: -webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#f4fbeb)) no-repeat;background:-o-linear-gradient(#fff 0%,#f4fbeb 100%) no-repeat;}a#logo{top:6px;background:url('images\/logo.png') no-repeat;_background-image: none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images\/logo.png', sizingMethod='image');}a{color:#333;}body a{_color:#333;}.cust-border-color,.channel li,.tabs li,.usage-tabs li,.pop-border,.mynav-line,.tipcon dl{border-color:#6cbb2a;}.tabs li{background-color:#f5fcec;}.tabs li.selected{background-color:#fff;}.side,.usage,.recom-area{background-color:#fbfef3;}.channel li.hover{background-color:#eaf8d7;}.usage-tabs li{background-color:#fff;}.usage-tabs li.selected{background-color:#fbfef3;}.poptip p,.tipcon{background-color:#fff;}.tipcon dl.hover{background-color:#f5fcec;}.main{background-color:#fefefe;}.kuzhan-nav{background-color:#f5fcec;}.kuzhan-nav a{border-color:#6cbb2a;}#suggests a{background-color:#f9fffc;}#suggests a.hover{background-color:#dcf5b0}"};
hao360.skin.orange={"previewImg":"","name":"\u6a59\u8272","iePreload":["images\/skin\/orange_bg.png","images\/skin\/orange_s_bg.png"],"sort":"default","css":".wrap-outer{background:#fff url(images\/skin\/orange_bg.png) repeat-x 0 0\\9;background:linear-gradient(#fff1e6 0%,#fff 15%) no-repeat;background:-moz-linear-gradient(#fff1e6 0%,#fff 15%) no-repeat;background: -webkit-gradient(linear, 0 0, 0 15%, from(#fff1e6), to(#fff)) no-repeat;background:-o-linear-gradient(#fff1e6 0%, #fff 15%) no-repeat;}.tabs-box{background:url(images\/skin\/orange_s_bg.png) repeat-x 0 0\\9;background: -moz-linear-gradient(#fff 0%,#fff7f4 100%) no-repeat;background: -webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#fff7f4)) no-repeat;background:-o-linear-gradient(#fff 0%,#fff7f4 100%) no-repeat;}a#logo{top:6px;background:url('images\/logo.png') no-repeat;_background-image: none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images\/logo.png', sizingMethod='image');}a{color:#333;}body a{_color:#333;}.cust-border-color,.channel li,.tabs li,.usage-tabs li,.pop-border,.mynav-line,.tipcon dl{border-color:#d7b89c;}.tabs li{background-color:#fdf8f4;}.tabs li.selected{background-color:#fff;}.side,.usage,.recom-area{background-color:#fffcf9;}.channel li.hover{background-color:#faf1e9;}.usage-tabs li{background-color:#fff;}.usage-tabs li.selected{background-color:#fffcf9;}.poptip p,.tipcon{background-color:#fff;}.tipcon dl.hover{background-color:#fdf8f4;}.main{background-color:#fefefe;}.kuzhan-nav{background-color:#fdf8f4;}.kuzhan-nav a{border-color:#d7b89c;}#suggests a{background-color:#fffdfb;}#suggests a.hover{background-color:#fed3ac}"};
(function(){
	new Image().src = "images/logo_def.png";
	var qload = qtool.load,skinKey = qtool.cookie.get(EXPSKIN)||hao360.nowSkinKey,timegap=qtool.cookie.get("timegap")||false;
	hostCache=qtool.cacheSvc.ins("hao360");
	if(timegap)
	{
		serverTime = todayObj.getTime()+(+timegap);
		todayObj = new Date(serverTime);
	}
	if(skinKey==="undefined")skinKey="blue";
	hao360.nowSkinKey = skinKey;
	hao360.drawSkin(skinKey);
	hao360.confirmSkin(skinKey);
	qload.add('jq',{path:'http://h.qhimg.com/js/jquery-1.6.2.min.js',charset:"utf-8"});
	hao360.cityCode = qtool.cookie.get("city_code")||"";
	if(!hao360.cityCode)
	{
		hao360.cityCode  = hostCache.get("city_code")||"";
		qtool.cookie.set("city_code",hao360.cityCode,{expires:365,domain:".www.tt365.org"});
	}
	else
	{
		if(document.cookie.indexOf("city_code")!==document.cookie.lastIndexOf("city_code"))
		{
			qtool.cookie.remove("city_code");
			qtool.cookie.remove("city_code",{domain:"www.tt365.org"});
			qtool.cookie.set("city_code",hao360.cityCode,{expires:365,domain:".www.tt365.org"});
		}
		hostCache.set("city_code",hao360.cityCode);
	}
	var sloVer = hostCache.get("sloVer")||"";
	if(sloVer!=="v2.1")
	{
		qtool.cacheSvc.ins("weather").clear();
		qtool.cacheSvc.ins("feed").clear();
		hostCache.set("sloVer","v2.1");
	}


})();
(function(){
	//耦合todayObj
	window.feedSvc = (function(){
		var loader = smartLoad.ins("feed"),
		dataFilter = function(data){
			var newData = data;
			newData.clientTime=todayObj.getTime(),newData.serverTime=+(data.time+"000");
			newData.timeGap=newData.serverTime-newData.clientTime;
			delete newData.time;
			return newData;
		},
		self,
		key = "info",
		feedData = null,
		expired = false;
		;
		loader.setup({callUrl:"js/hao-hot.js?v="+feedTime+"&_jsonp=?&t="+todayObj.getHours()+""+parseInt(todayObj.getMinutes()/30),dataFilter:dataFilter});
		loader.then("once",function(data,attr){
			if(attr.from==="local")
			{
				var _today = new Date(todayObj.getTime()+data.timeGap),
					todayDate = hao360.getFmtDate(_today);
				if(_today.getTime()-data.serverTime>180E5)
				{
					expired = true;
					loader.then("once",function(data){
						expired = false;
						feedData = data;
					})
					loader.update(key);
					return;
				}
				if(data.serverTime<feedTime)
				{
					loader.update(key,2000);
					return;
				}
				if(_today.getTime()-data.serverTime>36E5)
				{
					loader.update(key,6000);
				}
			}
		});
		loader.then("always",function(data){
			feedData = data;
		});
		loader.fetch(key);
		self = {
			fire:function(partName,drawFunc){
				var canWrite = true;
					fire = function(data){
						var parts = [partName];
						if(partName.indexOf(".")>0)
						{
							parts = partName.split(".",2);
						}
						if(expired&&parts[0]==="search")
						{
							loader.then("once",function(data){
								drawFunc.apply(null,[parts[1]?data.search[parts[1]]:data.search,false]);
							});
							return;
						}
						drawFunc.apply(null,[parts.length===2?data[parts[0]][parts[1]]:data[parts[0]],canWrite]);
				};
				if(!feedData){
					canWrite = false;
					loader.then("once",fire);
				}else{
					fire(feedData);
				}
				
			}
		};
		return self;
	})();
})();
(function(){
	window.weatherSvc = (function(){
		var dataFilter = function(data,oriData){
			var code=data.area[2][1],newData={weather:{}};
			if(!data.weather[1].info)
			{
				return oriData?oriData:null;
			}
			newData.clientTime=now.getTime(),newData.serverTime=+(data.time+"000");
			newData.timeGap=newData.serverTime-newData.clientTime;
			newData.areaName=[data.area[0][0],data.area[1][0],data.area[2][0]];
			newData.areaCode=[data.area[0][1],data.area[1][1],data.area[2][1]];
			for(var i=0,info,date,dayWeather;dayWeather=data.weather[i++];)
			{
				date = dayWeather.date;
				info = dayWeather.info;
				newData.weather[date] = {};
				newData.weather[date].dawn = info.dawn||(oriData&&oriData.weather[date]&&oriData.weather[date].dawn?oriData.weather[date].dawn:[0,"晴",""]);
				newData.weather[date].day = info.day||(oriData&&oriData.weather[date]&&oriData.weather[date].day?oriData.weather[date].day:[0,"晴",""]);
				newData.weather[date].night = info.night||(oriData&&oriData.weather[date]&&oriData.weather[date].night?oriData.weather[date].night:[0,"晴",""]);
			}
			return newData;
		},
		formatDate = function(dateObj){
			return dateObj.getFullYear()+'-'+("0"+(dateObj.getMonth()+1)).slice(-2)+'-'+("0"+dateObj.getDate()).slice(-2);
		},
		makeKey = function(cityCode){
			return "data-"+cityCode;
		},
		now = new Date(),
		loader = smartLoad.ins("weather"),
		self;
		loader.setup({dataFilter:dataFilter});
		self = {
			whenUpdate:function(cityCode,changeFunc){
				var currCode = cityCode;
				loader.then("always",function(data,attr){
					//currCode为空时 则自动会删除
					if(attr.from==="server"&&currCode!=data.areaCode[2])
					{
						currCode = data.areaCode[2];
						changeFunc.apply(null,[data.areaCode,data.areaName]);
						loader.remain(makeKey(currCode));
					}
				});
			},
			load:function(cityCode){
				return loader.fetch(makeKey(cityCode));
			},
			draw:function(cityCode,drawFunc){
				var key = makeKey(cityCode);
				loader.setup({callUrl:'http://'+(cityCode?"cdn.":"")+'weather.hao.360.cn/api_weather_info.php?app=hao360&_jsonp=?&code='+cityCode+'&t='+now.getDate()+''+now.getHours()+'.js'});
				loader.then("once",function(data,attr){
					if(attr.from==="local")
					{
						var _today = new Date(now.getTime()+data.timeGap),
							_tomor = new Date(_today.getTime()+864E5),
							todayDate = formatDate(_today),
							tomorDate = formatDate(_tomor);
						if(!data.weather[todayDate]||!data.weather[tomorDate]||(_today.getTime()-data.serverTime>180E5))
						{
							loader.then("once",function(data){
								drawFunc.apply(null,[data,false]);
							});
							loader.update(key);
							return;
						}
						if(_today.getTime()-data.serverTime>36E5)
						{
							loader.update(key,6000);
						}
					}
					drawFunc.apply(null,[data,attr.from==="local"?true:false]);
				});
				return loader.fetch(key);
			}
		};
		return self;
	})();
	weatherSvc.whenUpdate(hao360.cityCode||"",function(code,name){
		hao360.cityCode = code[2];
		hao360.place = name;
		qtool.cookie.set("city_code",hao360.cityCode,{expires:365,domain:".www.tt365.org"});
		hostCache.set("city_code",hao360.cityCode);
		hao360.loadLocalnav&&hao360.loadLocalnav(name);
	});
	var updateOptions = function(id,dataArr){
		if(dataArr&&dataArr.length>0)
		{
			var selectElem = _d(id);
			selectElem.length = dataArr.length;
			for(var i=0,dataElem,elem;dataElem=dataArr[i];i++){
				elem = selectElem.options[i];
				elem.value = dataElem[1];
				elem.innerHTML = dataElem[0];
			}
			selectElem.value = dataArr[0][1];
		}
	},queryAreaCb = {city:"weatherHelper.setCityOption",town:"weatherHelper.setTownOption"};
	window.weatherHelper = {
		generateHtml:function(data){
			function getPicStyle(id)
			{
				return "background:url('images/weather/hdico/"+id+".png') no-repeat;_background-image: none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/weather/hdico/"+id+".png', sizingMethod='image');";
			}
			var	_todayObj = new Date(new Date().getTime()+data.timeGap),
				_tomorObj = new Date(_todayObj.getTime()+864E5),
				todayDate = hao360.getFmtDate(_todayObj),
				tomorDate = hao360.getFmtDate(_tomorObj),
				todayInfo=data.weather[todayDate],
				tomorInfo=data.weather[tomorDate],
				todayDesc,tomorDesc,todayDegree,tomorDegree,
				d7url='//www.weather.com.cn/weather/'+data.areaCode[2]+'.shtml#7d',
				html = '<div class="weather-city"><div class="city-name">'+data.areaName[2]+'</div><a id="to-weatheropt">[切换]</a></div>';
			if(todayInfo)
			{
				var timeFlag = "dawn",curHour = _todayObj.getHours(),degreeArr=[];
				if(+todayInfo.day[2]>0&&+todayInfo.night[2]<0)
				{	
					todayInfo.night[2] = " "+todayInfo.night[2];
				}
				if(curHour<5&&todayInfo["dawn"])
				{
					timeFlag = "dawn",todayInfo.dawn[2]&&degreeArr.push(todayInfo.dawn[2]),todayInfo.day[2]&&degreeArr.push(todayInfo.day[2]);
				}
				else if(curHour<19&&todayInfo["day"])
				{
					timeFlag = "day",todayInfo.day[2]&&degreeArr.push(todayInfo.day[2]),todayInfo.night[2]&&degreeArr.push(todayInfo.night[2]);
				}
				else
				{
					timeFlag = "night",todayInfo.night[2]&&degreeArr.push(todayInfo.night[2]);
				}
				todayDegree = (degreeArr[0]||degreeArr[1]?degreeArr.join("~"):"0")+"℃";
				todayDesc = todayInfo[timeFlag][1];
				if(todayDesc.length===1)todayDesc = "&nbsp;&nbsp;"+todayDesc;
				html += '<a href="'+d7url+'" class="today" title="点击查看7日天气"><div class="weather-pic" style="'+getPicStyle(todayInfo[timeFlag][0])+'"></div><div class="weather-desc">今&nbsp;&nbsp;'+todayDesc+'</div><div class="temperature">'+todayDegree+'</div></a>';
			}
			else
			{
				html += '<a href="'+d7url+'" class="today"></a>';
			}
			if(tomorInfo&&tomorInfo.day)
			{
				if(+tomorInfo.day[2]>0&&+tomorInfo.night[2]<0)
				{	
					tomorInfo.night[2] = " "+tomorInfo.night[2];
				}
				var degreeArr=[];
				tomorDesc = tomorInfo.day[1];
				if(tomorDesc.length===1)tomorDesc = "&nbsp;&nbsp;"+tomorDesc;
				tomorInfo.day[2]&&degreeArr.push(tomorInfo.day[2]),tomorInfo.night[2]&&degreeArr.push(tomorInfo.night[2]);
				tomorDegree = (degreeArr[0]||degreeArr[1]?degreeArr.join("~"):"0")+"℃";
				html += '<a href="'+d7url+'" class="toworrow" title="点击查看7日天气"><div class="weather-pic" style="'+getPicStyle(tomorInfo.day[0])+'"></div><div class="weather-desc">明&nbsp;&nbsp;'+tomorDesc+'</div><div class="temperature">'+tomorDegree+'</div></a>';
			}
			else
			{
				html += '<a href="'+d7url+'" class="toworrow"></a>';
			}
			return html+'<a href="'+d7url+'" title="点击查看7日天气" class="future"></a>';
		},
		setCityOption:function(cityArr){
			updateOptions("weather-city",cityArr);
		},
		setTownOption:function(townArr){
			updateOptions("weather-town",townArr);
		},
		queryArea:function(grade,code,cb){
			qtool.load.add('queryArea',{path:"http://cdn.weather.hao.360.cn/api_area_query.php?grade="+grade+"&_jsonp="+queryAreaCb[grade]+"&code="+code,charset:"utf-8",type:"js",force:true});
			qtool.load("queryArea",cb);
		}
	};
})();