function setTime(){$(".time").each(function(){var i=String($(this).html()),n=i.substr(0,2),t;parseInt(n)<23?n++:n="00",t=i.substr(2,2),$(this).text(n+":"+t)});return}function formattime(){$(".shour").each(function(){var r=$(this).text().split(":"),n=parseInt(r[0]),u=parseInt(r[1]),i=parseInt(n)+3,t;t=n,u>=180&&count<2&&(n==6&&(t=0,i=12),n==18&&(t=12,i=24),n==0&&(t=0,i=12),n==12&&(t=12,i=24)),count++,$(this).css("display","inline"),$(this).html(t+" - "+i)});return}function daynightwicon(){d=new Date;var n=18;(d.getMonth()>8||d.getMonth()<3)&&(n=15),$(".wicon").each(function(){var r=$(this).text().split(":"),t=r[0],i=parseInt(r[1]);(i<6||i>n)&&(t="night/"+t),$(this).html('<img title="'+t.replace("night/sunny","night clear")+'" width="45px" height="25px" alt="Weather conditions" src="http://www.theweatheroutlook.com/Images/symbols/'+t+'.gif" />'),$(this).css("display","block")});return}function formatWeather(){var i=new Date,t=i.getHours(),n=i.getMonth();symbols="images/symbols/",(parseInt(t)>=18||parseInt(t)<=7)&&(n>8||n<3)?symbols="images/symbols/night/":(parseInt(t)>=20||parseInt(t)<=6)&&n<9&&n>2&&(symbols="images/symbols/night/"),$(".wtype").each(function(){var n=[],r=String($(this).text()),i,t;n=r.split(":",2),i="",t="http://theweatheroutlook.com/",n[1]=jQuery.trim(n[1]),n[1]!=""&&(n[1].indexOf("showers")<0?n[1].indexOf("snow")<0?n[1].indexOf("thunder")<0?n[1].indexOf("fog")<0?n[1].indexOf("haze")<0?n[1].indexOf("drizzle")<0?n[1].indexOf("cumulus")<0&&n[1].indexOf("Cumulonimbus")<0?n[1].indexOf("mist")<0?n[1].indexOf("rain")<0||$(this).html('<IMG height="27px" src="'+t+symbols+'heavyrain.gif">'):i=" Mist":$(this).html('<IMG height="27px" src="'+t+symbols+'mostcloud.gif">'):$(this).html('<IMG height="27px" src="'+t+symbols+'lightrain.gif">'):i=" Haze":$(this).html('<IMG height="27px" src="'+t+symbols+'fog.gif">'):$(this).html('<IMG height="27px" src="'+t+symbols+'thunderstorm.gif">'):$(this).html('<IMG height="27px" src="'+t+symbols+'snow.gif">'):$(this).html('<IMG height="27px" src="'+t+symbols+'shower.gif">')),n[1]!=""&&n[1].indexOf("haze")<0&&n[1].indexOf("mist")<0||(n[0].indexOf("clear")<0?n[0].indexOf("partly cloudy")<0&&n[0].indexOf("partly clear")<0?n[0].indexOf("mostly cloudy")<0?n[0].indexOf("overcast")<0&&n[0].indexOf("obscured")<0||$(this).html('<IMG height="27px" src="'+t+symbols+'cloudy.gif">'+i):$(this).html('<IMG height="27px" src="'+t+symbols+'mostcloud.gif">'+i):$(this).html('<IMG height="27px" src="'+t+symbols+'fair.gif">'+i):$(this).html('<IMG height="27px" src="'+t+symbols+'sunny.gif">'+i)),n[1]==""&&n[0]==""&&$(this).html('<IMG height="27px" src="'+t+symbols+'sunny.gif">'+i)});return}function formattemprange(){$(".temprange").each(function(){var t,n=$(this).text().split(":"),r=n[0],u=n[1],i=n[2];t=parseInt(i)>15||parseInt(i)<9?r:u,$(this).text(t+"\u00b0C"),$(this).css("display","block")});return}function formatwc(){$(".wcrange").each(function(){var t,n=$(this).text().split(":"),e=n[0],f=n[1],i=n[2],r=n[3],u;t=parseInt(i)>15||parseInt(i)<9?e:f,u=Math.round(13.12+.6215*parseInt(t)-11.37*Math.pow(parseInt(r),.16)+.3965*parseInt(t)*Math.pow(parseInt(r),.16)),$(this).text(u+"\u00b0C"),$(this).css("display","block")});return}function formatTemp(){$(".temps, .wc").each(function(){var t=$(this).text().indexOf("\u00b0F")>=0,n=parseInt($(this).text().replace("/[^0-9]/g",""));t?n<-80?$(this).text(""):n<32?$(this).addClass("blue"):n>31&&n<70?$(this).addClass("green"):n>69&&n<75?$(this).addClass("orange"):n>74&&$(this).addClass("red"):n<-80?$(this).text(""):n<0?$(this).addClass("blue"):n>-1&&n<21?$(this).addClass("green"):n>20&&n<25?$(this).addClass("orange"):n>24&&$(this).addClass("red")});return}function formatRainT(){$(".raint").each(function(){var n=parseInt($(this).text());n>5?$(this).addClass("red"):n>2?$(this).addClass("orange"):n>1?$(this).addClass("green"):n>0?$(this).addClass("blue"):$(this).addClass("grey")});return}function formatWindSpeed(){$(".winds").each(function(){var t=$(this).text().indexOf("mph")>=0,n=parseInt($(this).text().replace("/[^0-9]/g",""));t?n>50?$(this).addClass("red"):n>29&&n<51?$(this).addClass("orange"):n>14&&n<30?$(this).addClass("green"):n<15&&$(this).addClass("blue"):n>80?$(this).addClass("red"):n>47&&n<81?$(this).addClass("orange"):n>22&&n<48?$(this).addClass("green"):n<23&&$(this).addClass("blue")});return}function formatrh(){$(".rhum").each(function(){var n=parseInt($(this).text().replace("/[^0-9]/g",""));parseInt(n)>85?$(this).addClass("red"):parseInt(n)>70?$(this).addClass("orange"):parseInt(n)>50?$(this).addClass("green"):parseInt(n)>50?$(this).addClass("blue"):$(this).addClass("grey")});return}function formatcc(){$(".cc").each(function(){var n=Math.round(parseInt($(this).text().replace("/[^0-9]/g",""))/10)*10;$(this).addClass("grey"+n.toString())});return}function formatWindDir(){symbols="images/symbols/",$(".windsdir").each(function(){var n=parseInt($(this).text().replace("/[^0-9]/g","")),t="http://theweatheroutlook.com/";n>337||n<23?$(this).html('<IMG src="'+t+symbols+'north1.gif">'):n>22&&n<68?$(this).html('<IMG src="'+t+symbols+'northeast1.gif">'):n>67&&n<113?$(this).html('<IMG src="'+t+symbols+'east1.gif">'):n>112&&n<158?$(this).html('<IMG src="'+t+symbols+'southeast1.gif">'):n>157&&n<203?$(this).html('<IMG src="'+t+symbols+'south1.gif">'):n>156&&n<248?$(this).html('<IMG src="'+t+symbols+'southwest1.gif">'):n>247&&n<293?$(this).html('<IMG src="'+t+symbols+'west1.gif">'):n>292&&n<338&&$(this).html('<IMG src="'+t+symbols+'west1.gif">')});return}function buildhtml(n){var r=$("#fdata").text(),i=jQuery.parseJSON(r),t="";return t='<table class="sub">',t=t+"<thead><tr>",t=t+"<th>Time</th>",t=t+"<th>Weather</th>",t=t+"<th>Temp</th>",t=t+"<th>Feels</th>",t=t+"<th>Rain</th>",t=t+"<th>Cloud</th>",t=t+"<th>Speed</th>",t=t+"<th>Gust</th>",t=t+"<th>Dir</th>",t=t+"<th>Hum</th>",t=t+"<th>Press</th>",t=t+"</tr></thead>",$.each(i,function(r){if(n==i[r].fd){t=t+"<tr>";if(i[r].fh!=null){var f,o,e,h="m",s="c";f=parseInt(i[r].fh)>15||parseInt(i[r].fh)<9?i[r].tmi:i[r].tmx,ckunitsnow!=null?(ckunitsnow.substring(0,1)=="m"?(o=parseInt(i[r].ws),e=parseInt(i[r].wg),windunit="mph"):ckunitsnow.substring(0,1)=="k"?(windunit="kph",o=Math.round(parseInt(i[r].ws)*1.609),e=Math.round(parseInt(i[r].wg)*1.609)):(windunit="kts",o=Math.round(parseInt(i[r].ws)*.87),e=Math.round(parseInt(i[r].wg)*.87)),ckunitsnow.substring(1,2)=="c"?tempunit="\u00b0C":(f=Math.round(parseInt(f)*9/5+32),tempunit="\u00b0F")):(windunit="mph",tempunit="\u00b0C",o=parseInt(i[r].ws),e=parseInt(i[r].wg)),t=t+"<td>",t=t+fortime(i[r].fh,i[r].ha),t=t+"</td>",t=t+"<td>",t=t+wicon(i[r].ci,i[r].fh),t=t+"</td>",t=t+"<td class="+tempclass(f)+'><span class="temps">',t=t+f,t=t+" "+tempunit+"</span></td>",t=t+"<td class="+wcclass(f)+'><span class="temps">',t=t+wc(f,i[r].ws),t=t+" "+tempunit+"</span></td>",t=t+"<td class="+rainclass(i[r].rt)+">",t=t+i[r].rt,t=t+" mm</td>",t=t+"<td class="+cloudcovclass(i[r].cc)+">",t=t+i[r].cc,t=t+" %</td>",t=t+"<td class="+windspeedclass(i[r].ws)+'><span class="winds">',t=t+o,t=t+" "+windunit+"</span></td>",t=t+"<td class="+windspeedclass(i[r].wg)+'><span class="winds">',t=t+e,t=t+" "+windunit+"</span></td>",t=t+"<td>",t=t+windicon(i[r].wk),t=t+"</td>",t=t+"<td class="+rhclass(i[r].rh)+">",t=t+i[r].rh,t=t+" %</td>",t=t+'<td class="grey">',t=t+i[r].sp,t=t+" mB</td>"}t=t+"</tr>"}}),t=t+"</table>"}function fortime(n,t){var i=parseInt(n),r=parseInt(i)+3;return t>=180&&count<2&&(i==6&&(i=0,r=12),i==18&&(i=12,r=24),i==0&&(i=0,r=12),i==12&&(i=12,r=24)),count++,i+" - "+r}function wc(n,t){var i=13.12+.6215*parseInt(n)-11.37*Math.pow(parseInt(t),.16)+.3965*parseInt(n)*Math.pow(parseInt(t),.16);return Math.round(i)}function wcclass(n,t){var r,i;return tempunit=="\u00b0F"&&(n=(parseInt(n)-32)/9*5),r=13.12+.6215*parseInt(n)-11.37*Math.pow(parseInt(t),.16)+.3965*parseInt(n)*Math.pow(parseInt(t),.16),r=Math.round(r),i="",i=parseInt(r)<0?"blue":parseInt(r)>24?"red":parseInt(r)>21?"orange":"green"}function windspeedclass(n){windunit=="kts"&&(n=Math.round(parseInt(n)*1.15)),windunit=="kph"&&(n=Math.round(parseInt(n)/1.609));var t;return t=n>50?"red":n>30?"orange":n>10?"green":"blue"}function tempclass(n){tempunit=="\u00b0F"&&(n=(parseInt(n)-32)/9*5);var t;return t=parseInt(n)<0?"blue":parseInt(n)>24?"red":parseInt(n)>20?"orange":"green"}function rainclass(n){var t;return t=parseFloat(n)>5?"red":parseFloat(n)>2?"orange":parseFloat(n)>1?"green":parseFloat(n)>0?"blue":"grey"}function cloudcovclass(n){var i=Math.round(parseInt(n)/10)*10;return"grey"+i.toString()}function wicon(n,t){var u=18,f=new Date,i,r;return(f.getMonth()>8||f.getMonth()<3)&&(u=15),i=parseInt(t),(i<6||i>u)&&(n="night/"+n),r='<img title="'+n.replace("night/sunny","night clear")+'" width="45px" height="25px" alt="Weather conditions" src="http://www.theweatheroutlook.com/Images/symbols/'+n+'.gif" />'}function windicon(n){return'<img title="Wind direction" alt="Wind direction" src="http://www.theweatheroutlook.com/Images/symbols/'+n+'.gif" />'}function rhclass(n){var t;return t=parseInt(n)>85?"red":parseInt(n)>70?"orange":parseInt(n)>50?"green":parseInt(n)>50?"blue":"grey"}function showDate(){$(".fdate").each(function(){$(this).text()==fdate&&$(this).css("display","none"),fdate=$(this).text()});return}$(document).ready(function(){var r,n,t;fdate="",$("#tabnow").length>0;try{$("#tabnow").tablesorter({textExtraction:function(n){var t=n.innerHTML.replace(/[^0-9]/g,"");return t==""&&(t=n.innerHTML),t}})}catch(i){}count=0,setTime(""),formattemprange(),formatwc(),formatTemp(),formatWindSpeed(),formatWindDir(),formatWeather(),formatrh(),formatcc(),formattime(),formatRainT(),daynightwicon(),$("#wncon").css("display","block"),$("#wnloading").css("display","none"),tempunit="",windunit="",$("#df a").click(function(){count=0,ckunitsnow=$.cookie("twounits"),n!=null&&$("#"+n).css("display","none");var i="trd"+this.id,r="tr"+this.id;return $("#"+i).css("display","table-row"),$("#"+r).text().indexOf("Show")>-1&&$("#"+r+" .show").text("Hide details "),$("#"+i).css("background-color","#b4c7e2"),$("#"+r).css("background-color","#b4c7e2"),$("#"+n).css("background-color","#e6eae8"),$("#"+t).css("background-color","#e6eae8"),$("#"+t).text().indexOf("Hide")>-1&&($("#"+n).css("display","none"),$("#"+t+" .show").text("Show details")),$("#"+i).html(""),$("#"+i).html('<td colspan="7">'+buildhtml(this.id)+"</td>"),n!=i?(n=i,t=r):(n=-1,t=-1),!1})})
