var _id=4074;var _zona="italy";var _link="italia/lombardia/milano/";var METEO_LOCATION=location.protocol+"//"+location.hostname+"/";var WIDGET_LOCATION="widget/meteo/widget.html";var GADGET_LOCATION="widget/meteo/gadget.xml";var NETVIBES_LOCATION="widget/meteo/netvibes.xml";var STRING_LOADING="Caricamento...";var STRING_ERROR="I dati meteo non sono ancora disponibili.";var REFRESH_INTERVAL=30;var _locSelected=null;var _IsExpanded=true;var currentRequest=null;function getUrlVars(){var d=[],c;var a=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var b=0;b<a.length;b++){c=a[b].split("=");d.push(c[0]);d[c[0]]=c[1]}return d}function getExportHTML(){var a="?id="+_id+"&zona="+_zona+"&link="+_link;return'<iframe id="wdgtmeteoframe" src="http://meteo.sky.it/'+WIDGET_LOCATION+'" width="100%" height="370px" scrolling="no" style="border: 0px" frameborder="0"/>'}function createCookie(c,d,e){var a="";if(e){var b=new Date();b.setTime(b.getTime()+(e*24*60*60*1000));a="; expires="+b.toGMTString()}document.cookie=c+"="+d+a+"; path=/"}function readCookie(b){var e=b+"=";var a=document.cookie.split(";");for(var d=0;d<a.length;d++){var f=a[d];while(f.charAt(0)===" "){f=f.substring(1,f.length)}if(f.indexOf(e)===0){return f.substring(e.length,f.length)}}return null}function eraseCookie(a){createCookie(a,"",-1)}function getAutosuggestRequestData(a){return"?q="+a.val()+"&timestamp="+(new Date()).getTime()}function autosuggestSelect(a){$("#salva").addClass("accept");$("#salva").removeClass("acceptDis");_locSelected=a}function autosuggestUnSelect(){$("#salva").addClass("acceptDis");$("#salva").removeClass("accept");_locSelected=null}function displayMessage(a){$(".AllTabs").html('<div class="TabLoading">'+a+"</div>");$(".TabMenu").html("");$("#cityLabel").html("");$("#countryLabel").html("");$("#forecast_box_left").html("");$("#forecast_box_right_innerLeft").html("");$("#forecast_box_right_innerRight").html("");$(".AllTabs").css({left:0+"px"});setTimeout(function(){$(".TabLoading").fadeIn("slow")},1000)}function formatTabData(d,b){var a=d.time.split("T",2);var c=a[1].split(":");var e=parseInt(c[0],10);if(b){html='<span id="def">'}else{html="<span>"}html+=e+"</span>";return html}function formatWeatherData(g,d){var c=g.time.split("T",2);var f=c[1].split(":");var h=parseInt(f[0],10);var a="";if(d){a='id="def"'}var b="";if(h>20||h<4){b="_night"}var e='<div class="TabContent" '+a+'><div class="weatherIcon"><div class="center_icon_big2"><div class="'+g.icon+"_big2"+b+'"/></div></div><div class="weatherTemp">'+g.temperature+'&deg;</div><div class="weatherCond">'+g.description.substr(0,1).toUpperCase()+g.description.substr(1)+"</div></div>";return e}function formatForecast(g){var d=g.time.split("T",2);var a=d[0].split("-",3);var e=new Date(a[0],a[1]-1,a[2]);var c=e.getDay();var f=["DOM","LUN","MAR","MER","GIO","VEN","SAB","DOM"];var b="<div>"+f[c]+'<div class="forecast_temp"><div></div></div><div class="center_icon_mid"><div class="'+g.icon+'_mid"/></div><div class="forecast_temp">'+g.temperature+"&deg;</div></div>";return b}function displayWeather(d){$("#countryLabel").html(d.location.continent);$("#cityLabel").html(d.location.name);var c="";var e="";for(var b=0;b<d.day_0.length;b++){c+=formatTabData(d.day_0[b],b==1);e+=formatWeatherData(d.day_0[b],b==1)}$("#TabMenu").html(c);$("#AllTabs").html(e);$("#forecast_box_left").html(formatForecast(d.day_1[1]));$("#forecast_box_right_innerLeft").html(formatForecast(d.day_2[1]));$("#forecast_box_right_innerRight").html(formatForecast(d.day_3[1]));var a=$(".TabContent:first").width();$(".container .TabMenu span#def").addClass("selector");$(".AllTabs").css({left:-a+"px"});$(".container .TabMenu span").mouseover(function(){$(this).addClass("hovering")});$(".container .TabMenu span").mouseout(function(){$(this).removeClass("hovering")});$(".container .TabMenu span").click(function(){$(".selector").removeClass("selector");$(this).addClass("selector");var f=(1-$("span").index(this))*a;$(".AllTabs").animate({left:+f+"px"},500)});createCookie("id",_id);createCookie("zona",_zona);createCookie("link",_link);setTimeout("sendWeatherRequest()",60000*REFRESH_INTERVAL)}function weatherRequestError(a,c,b){displayMessage(STRING_ERROR)}function sendWeatherRequest(){displayMessage(STRING_LOADING);if(currentRequest!==null&&currentRequest.readyState!==4){currentRequest.abort()}currentRequest=$.ajax({type:"GET",url:METEO_LOCATION+"Meteo24Backend/jsfc.do?id="+_id+"&loc="+_zona,dataType:"json",success:displayWeather,error:weatherRequestError})}function init(){displayMessage(STRING_LOADING);var a=$("#exportBox").width();$("#container").css({left:-a+"px"});$(window).resize(function(){a=$("#exportBox").width();$("#container").css({left:-a+"px"})});$("#expanderToggle").toggle(function(){_IsExpanded=false;$("#forecastBox").slideToggle("slow");$("#expanderLabel").html("Espandi");$("#expanderButton").addClass("expanderButtonBottom");$("#expanderButton").removeClass("expanderButtonTop")},function(){_IsExpanded=true;$("#forecastBox").slideToggle("slow");$("#expanderLabel").html("Reduci");$("#expanderButton").addClass("expanderButtonTop");$("#expanderButton").removeClass("expanderButtonBottom")});$("#configWidget").click(function(){$("#salva").addClass("acceptDis");$("#salva").removeClass("accept");_locSelected=null;$("#loc_search").val("");$("#container").animate({left:-2*a+"px"},500)});$("#grabWidget").click(function(){$("#exportTags").attr("value",getExportHTML());$("#container").animate({left:0+"px"},500)});$("#salva").click(function(){if(_locSelected!==null){_id=_locSelected.id;if(_locSelected.zona=="italia"){_zona="italy"}else{_zona="world"}_link=_locSelected.link;sendWeatherRequest();$("#container").animate({left:-a+"px"},500)}});$(".annulla").click(function(){$("#container").animate({left:-a+"px"},500)});$("#loc_search").mimass({url:METEO_LOCATION+"Meteo24Backend/locations.do",url:METEO_LOCATION+"Meteo24Backend/locations.do",requestDataCallback:getAutosuggestRequestData,onSelect:autosuggestSelect,onUnSelect:autosuggestUnSelect});$(".logo").click(function(){window.open(METEO_LOCATION)});$("#igoogle").click(function(){window.open("http://fusion.google.com/add?source=atgs&moduleurl="+escape(METEO_LOCATION+GADGET_LOCATION))});$("#netvibes").click(function(){window.open("http://www.netvibes.com/subscribe.php?module=UWA&moduleUrl="+escape(METEO_LOCATION+NETVIBES_LOCATION))});$("#previsioni").click(function(){if(_link!==null){window.open(METEO_LOCATION+"meteo/previsioni/"+_link)}else{window.open(METEO_LOCATION)}});$("#cityLabel").click(function(){if(_link!==null){window.open(METEO_LOCATION+"meteo/previsioni/"+_link)}else{window.open(METEO_LOCATION)}});$("textarea").click(function(){this.select()});var b=getUrlVars();if(b.id&&b.zona){_zona=b.zona;_id=b.id;_link=b.link}else{if(readCookie("id")!==null&&readCookie("id")!==undefined&&readCookie("link")!==null&&readCookie("link")!==undefined&&readCookie("zona")!==null&&readCookie("zona")!==undefined){_id=readCookie("id");_link=readCookie("link");_zona=readCookie("zona")}}sendWeatherRequest()};
