(function(a){a.fn.weather=function(b){var c=a.extend({},a.fn.weather.defaults,b);return this.each(function(){$this=a(this);$this.weather.getWeather($this,c)})};a.fn.weather.getWeather=function(g,c){var e,b,f,d;e=a.extend({},a.fn.weather.defaults,c);b=e.feed+e.location+"&u="+e.units;f;d=false;a.ajax({cache:false,dataType:"xml",type:"GET",url:b,complete:function(q,j){if(d){var l,o,m,n,h,p,k,i;l=a.fn.weather.response;o=a(f);m=a("rss channel ttl",o).next();n=m.next();l.location=m.attr("city");l.units.temperature=n.attr("temperature");g.append("<p>"+e.title.replace("{location}",l.location)+"</p>");h=a("rss>channel>item>pubDate",o).next();l.current.code=h.attr("code");l.current.condition=h.attr("text");l.current.temperature=h.attr("temp");l.current.image=e.image_base_url.replace("{img}",l.current.code);p=a("rss>channel>item>description",o).next();l.forecast.today.date=p.attr("date");l.forecast.today.shortdate=(new Date(l.forecast.today.date)).format("dd MMM").toLowerCase();l.forecast.today.low=p.attr("low");l.forecast.today.high=p.attr("high");l.forecast.today.code=p.attr("code");l.forecast.today.condition=p.attr("text");l.forecast.today.image=e.image_base_url.replace("{img}",l.forecast.today.code);p=p.next();l.forecast.tomorrow.date=p.attr("date");l.forecast.tomorrow.shortdate=(new Date(l.forecast.tomorrow.date)).format("dd MMM").toLowerCase();l.forecast.tomorrow.low=p.attr("low");l.forecast.tomorrow.high=p.attr("high");l.forecast.tomorrow.code=p.attr("code");l.forecast.tomorrow.condition=p.attr("text");l.forecast.tomorrow.image=e.image_base_url.replace("{img}",l.forecast.tomorrow.code);k="<ul>";k+='<li class="current"><span class="cond">'+l.current.condition+'</span><span class="date">Hoy</span> <span class="temp">'+a.fn.weather.displayTempUnits(l.current.temperature,l.units.temperature)+'</span> <span class="min-max">'+a.fn.weather.displayTempUnits(l.forecast.today.low)+" / "+a.fn.weather.displayTempUnits(l.forecast.today.high)+"</span></li>";k+="</ul>";k+='<table class="forecast" border="0" cellspacing="2" cellpadding="2" align="center">';k+='<tr><td class="date">'+l.forecast.today.shortdate+'</td><td class="temp">'+a.fn.weather.displayTempUnits(l.forecast.today.low,l.units.temperature)+" / "+a.fn.weather.displayTempUnits(l.forecast.today.high,l.units.temperature)+'</td><td class="cond" style="background-image:url('+l.forecast.today.image+')">'+l.forecast.today.condition+"</td></tr>";k+='<tr><td class="date">'+l.forecast.tomorrow.shortdate+'</td><td class="temp">'+a.fn.weather.displayTempUnits(l.forecast.tomorrow.low,l.units.temperature)+" / "+a.fn.weather.displayTempUnits(l.forecast.tomorrow.high,l.units.temperature)+'</td><td class="cond" style="background-image:url('+l.forecast.tomorrow.image+')">'+l.forecast.tomorrow.condition+"</td></tr>";k+="</table>";p=a(k);a("li.current .cond",p).attr("style","background-image:url("+l.current.image+");");g.append(p);i=a('<a href="" target="_blank"></a>').attr("href",a("rss>channel>link",o).text()).text(a("rss>channel>title",o).text());g.append(a('<p class="reference"></p>').html(i))}},success:function(h,i){f=h;d=true},error:function(h,j,i){}})};a.fn.weather.displayTempUnits=function(d,b){var c="";c+=d+"&deg;";return c};a.fn.weather.response={location:"",units:{temperature:"C",distance:"km",pressure:"mb",speed:"kph"},current:{temperature:"",condition:"",code:"",image:""},forecast:{today:{date:"",shortdate:"",low:"",high:"",condition:"",code:"",image:""},tomorrow:{date:"",shortdate:"",low:"",high:"",condition:"",code:"",image:""}},reference:{title:"",url:""}};a.fn.weather.defaults={feed:"feed/weather.ashx?p=",location:"SPXX0015",units:"c",title:"El tiempo {location}",image_base_url:"http://l.yimg.com/a/i/us/nws/weather/gr/{img}s.png"}})(jQuery);