function setCookie(b,a){a.length>0&&$.cookie(b,a,{domain:".theweatheroutlook.com",path:"/",expires:1e3});return}function dispgraph(b){var a="twograph";if(b==0){$("#sgra").addClass("show");$("#sgra").removeClass("hide");$("#hgra,#frwsg").addClass("hide");$("#hgra,#frwsg").removeClass("show");setCookie(a,"0");drawChart()}else{$("#sgra").removeClass("show");$("#sgra").addClass("hide");$("#hgra,#frwsg").addClass("show");$("#hgra,#frwsg").removeClass("hide");setCookie(a,"1");drawChart()}}function drawChartInd(h,b,p,o){var n=$("#fdata").text(),a=jQuery.parseJSON(n),j=[],m=a.length-1,l=1;$.each(a,function(k){var o=0,c=10,m=new Array(1);m[0]=new Array(l);m[0][o]=a[k].fdt.toString()+" "+a[k].fh.toString()+" GMT";var h=parseInt(a[k].cc),g=parseInt(a[k].rt),f=parseInt(a[k].tmx),e=parseInt(a[k].ws),d=parseInt(a[k].rh),n=parseInt(a[k].fh),i=a[k].fdt.substring(7,10).toLowerCase();if(b=="cr_bat"){if(h<40)c=c;else if(h>39&h<60)c=c-1;else if(h>59)c=c-2;if(g<1)c=c;else if(g>0&g<2)c=c-2;else if(g>1&g<4)c=c-6;else if(g>3)c=0;if(f<5)c=c-4;else if(f>4&f<10)c=c-3;else if(f>9&f<15)c=c-2;else if(!(f>14&f<28))if(f>27)c=c-2;if(e>=5)if(e>4&e<10)c=c-1;else if(!(e>9&e<15))if(e>14&e<28)c=c+1;else if(e>27&e<50)c=c-2;else if(e>49)c=c-5;if(d<5)c=c-3;else if(d>4&d<30)c=c-2;else if(!(d>29&d<60))if(d>59&d<70)c=c-1;else if(d>69&d<90)c=c-2;else if(d>89)c=c-5;if(i=="nov"||i=="dec"||i=="jan"||i=="feb"||i=="mar")c=0;if(n<12||n>15)c=0}else if(b=="cr_bow"){if(h<40)c=c-3;else if(h>39&h<60)c=c-1;else if(!(h>59&h<80))if(h>79)c=c+1;if(g>=1)if(g>0&g<2)c=c-2;else if(g>1&g<3)c=c-3;else if(g>2&g<4)c=c-4;else if(g>3)c=0;if(f<5)c=c-6;else if(f>4&f<10)c=c-3;else if(f>9&f<15)c=c-2;else if(!(f>14&f<28))if(f>27)c=c+2;if(e>=5)if(e>4&e<10)c=c-1;else if(e>9&e<15)c=c-1;else if(e>14&e<28)c=c+1;else if(e>27&e<50)c=c-2;else if(e>49)c=c-5;if(d<5)c=c-3;else if(d>4&d<30)c=c-2;else if(!(d>29&d<60))if(d>59&d<70)c=c+1;else if(d>69&d<90)c=c+3;else if(d>89)c=c+7;if(i=="nov"||i=="dec"||i=="jan"||i=="feb"||i=="mar")c=0;if(n<12||n>15)c=0}else if(b=="gi"){if(h>=40)if(h>39&h<60)c=c-1;else if(h>59&h<80)c=c-2;else if(h>79)c=c-3;if(g>=1)if(g>0&g<2)c=c-2;else if(g>1&g<3)c=c-3;else if(g>2&g<4)c=c-6;else if(g>3)c=0;if(f<5)c=c-6;else if(f>4&f<10)c=c-3;else if(f>9&f<15)c=c-2;else if(!(f>14&f<28))if(f>27)c=c-2;if(e>=5)if(e>4&e<10)c=c-1;else if(e>9&e<15)c=c-2;else if(e>14&e<28)c=c-3;else if(e>27&e<50)c=c-4;else if(e>49)c=c-5;if(d<5)c=c-3;else if(d>4&d<30)c=c-2;else if(!(d>29&d<60))if(d>59&d<70)c=c-1;else if(d>69&d<90)c=c-3;else if(d>89)c=c-5}else if(b=="fi"){if(h<40)c=c-3;else if(h>39&h<60)c=c-1;else if(!(h>59&h<80))h>79;if(g>=1)if(g>0&g<2)c=c+1;else if(g>1&g<3)c=c+2;else if(g>2&g<4)c=c+2;else if(g>3)c=c+2;if(f<5)c=c-7;else if(f>4&f<10)c=c-5;else if(f>9&f<15)c=c-1;else if(f>14&f<22)c=c+1;else if(f>21&f<28)c=c+1;else if(f>27)c=c+1;if(e>=5)if(e>4&e<10)c=c-2;else if(e>9&e<15)c=c-1;else if(!(e>14&e<28))if(!(e>27&e<50))e>49;if(d<5)c=c-2;else if(d>4&d<30)c=c-1;else if(!(d>29&d<60))if(d>59&d<70)c=c+1;else if(d>69&d<90)c=c+1;else if(d>89)c=c+2}else if(b=="oi"){if(h<40)c=c+3;else if(h>39&h<60)c=c+2;else if(!(h>59&h<80))h>79;if(g>=1)if(g>0&g<2)c=c-2;else if(g>1&g<3)c=c-8;else if(g>2&g<4)c=0;else if(g>3)c=0;if(f<5)c=c-3;else if(f>4&f<10)c=c-2;else if(f>9&f<15)c=c-1;else if(f>14&f<22)c=c+1;else if(!(f>21&f<28))if(f>27)c=c-2;if(e>=5)if(!(e>4&e<10))if(e>9&e<15)c=c-1;else if(e>14&e<28)c=c-2;else if(e>27&e<50)c=c-3;else if(e>49)c=c-4;if(d<5)c=c-2;else if(d>4&d<30)c=c-1;else if(!(d>29&d<60))if(d>59&d<70)c=c-1;else if(d>69&d<90)c=c-2;else if(d>89)c=c-3}o++;if(c<0)c=0;if(c<0)c=0;if(c>10)c=10;m[0][o]=c;j.push(m)});var c=new google.visualization.DataTable,f=[];c.addColumn("string","Date");var d=String().empty;if(b=="cr_bat"){c.addColumn("number","Batting Index");f.push("Batting Index");d="Batting Index"}if(b=="cr_bow"){c.addColumn("number","Bowling Index");f.push("Bowling Index");d="Bowling Index"}if(b=="gi"){c.addColumn("number","Golf Index");f.push("Golf Index");d="Golf Index"}if(b=="fi"){c.addColumn("number","Fishing Index");f.push("Fishing Index");d="Fishing Index"}if(b=="oi"){c.addColumn("number","Outdoors Index");f.push("Outdoors Index");d="Outdoors Index"}for(var i=0;i<m;i++)c.addRows(j[i]);var k=$("#lbpcf_hid").val()+" 16 day outlook  - \u00a9 TheWeatherOutlook",g;g={title:k,width:625,height:450,backgroundColor:{fill:"#e5e5e5"},chartArea:{width:500,left:100},fontName:'"Arial"',hAxis:{title:"Forecast date",titleTextStyle:{color:"#000"},titlePosition:"out",slantedText:true,showTextEvery:12,textStyle:{fontSize:8}},vAxis:{title:d,minValue:p,maxValue:o},legend:{position:"top"}};var e;if($("#gvlg").attr("checked")){e=new google.visualization.LineChart(document.getElementById(h));e.draw(c,g)}else if($("#gvcc").attr("checked")){e=new google.visualization.ColumnChart(document.getElementById(h));e.draw(c,g)}else{e=new google.visualization.AreaChart(document.getElementById(h));e.draw(c,g)}}function drawChart(g,e,l,k,i,j){if(!g)g="chart_div";if(!i)i=450;if(!j)j=100;if(!e)e=false;if(!l)l=0;if(!k)k=0;var s=$("#fdata").text(),a=jQuery.parseJSON(s),n=[],p=[];$("#gvars :checked").each(function(){p.push($(this).attr("id"))});var r=a.length-1,q=p.length;$.each(a,function(d){var c=new Array(1);c[0]=new Array(q);var b=0;c[0][b]=a[d].fdt.toString()+" "+a[d].fh.toString()+" GMT";b++;if($("#cc").attr("checked")){c[0][b]=parseInt(a[d].cc);b++}if($("#fl").attr("checked")){c[0][b]=parseInt(a[d].fl);b++}if($("#rt").attr("checked")){if(!e)c[0][b]=parseInt(a[d].rt);else if(parseInt(a[d].rt)>2.9)c[0][b]=parseInt(a[d].rt);else c[0][b]=0;b++}if($("#sn").attr("checked")){if(e)if(a[d].ci.indexOf("snow")>=0||a[d].ci=="blizzard")c[0][b]=parseInt(a[d].rt);else c[0][b]=0;b++}if($("#rh").attr("checked")){c[0][b]=parseInt(a[d].rh);b++}if($("#sp").attr("checked")){c[0][b]=parseInt(a[d].sp);b++}if($("#tmin").attr("checked")){if(!e)c[0][b]=parseInt(a[d].tmi);else if(parseInt(a[d].tmi)<5)c[0][b]=parseInt(a[d].tmi);else c[0][b]=0;b++}if($("#tmax").attr("checked")){c[0][b]=parseInt(a[d].tmx);b++}if($("#ws").attr("checked")){c[0][b]=parseInt(a[d].ws);b++}if($("#wg").attr("checked")){if(!e)c[0][b]=parseInt(a[d].wg);else if(parseInt(a[d].wg)>44)c[0][b]=parseInt(a[d].wg);else c[0][b]=0;b++}n.push(c)});var c=new google.visualization.DataTable,d=[];c.addColumn("string","Date");var b=String().empty;if($("#cc").attr("checked")){c.addColumn("number","Cloud cover (%)");d.push("Cloud cover (%)");b="Cloud cover (%)"}if($("#fl").attr("checked")){c.addColumn("number","Freezing level (m)");d.push("Freezing level (m)");if(!b)b="Freezing level (m)"}if($("#rt").attr("checked")){c.addColumn("number","Precipitation (mm)");d.push("Precipitation (mm)");if(!b)b="Precipitation (mm)"}if($("#sn").attr("checked")){c.addColumn("number","Snow (cm)");d.push("Snow (cm)");if(!b)b="Snow(cm)"}if($("#rh").attr("checked")){c.addColumn("number","Humidity (%)");d.push("Humidity (%)");if(!b)b="Humidity (%)"}if($("#sp").attr("checked")){c.addColumn("number","Surface pressure (mB)");d.push("Surface pressure (mB)");if(!b)b="Surface pressure (mB)"}if($("#tmin").attr("checked")){c.addColumn("number","Min Temp (C)");d.push("Min Temp (C)");if(!b)b="Min Temp (C)"}if($("#tmax").attr("checked")){c.addColumn("number","Max Temp (C)");d.push("Max Temp (C)");if(!b)b="Max Temp (C)"}if($("#ws").attr("checked")){c.addColumn("number","Wind speed (mph)");d.push("Wind speed (mph)");if(!b)b="Wind speed (mph)"}if($("#wg").attr("checked")){c.addColumn("number","Wind gust (mph)");d.push("Wind gust (mph)");if(!b)b="Wind gust (mph)"}for(var m=0;m<r;m++)c.addRows(n[m]);var o=$("#lbpcf_hid").val()+" 16 day outlook  - \u00a9 TheWeatherOutlook",h;if(e)h={title:o,width:625,height:450,backgroundColor:{fill:"#e5e5e5"},chartArea:{width:i,left:j},fontName:'"Arial"',hAxis:{title:"Forecast date",titleTextStyle:{color:"#000"},titlePosition:"out",slantedText:true,showTextEvery:12,textStyle:{fontSize:8}},vAxis:{title:b,minValue:l,maxValue:k},legend:{position:"top"}};else h={title:o,width:625,height:450,chartArea:{width:i,left:j},fontName:'"Arial"',hAxis:{title:"Forecast date",titleTextStyle:{color:"#000"},titlePosition:"out",slantedText:true,showTextEvery:12,textStyle:{fontSize:8}},vAxis:{title:b},legend:{position:"top"}};var f;if($("#gvlg").attr("checked")){f=new google.visualization.LineChart(document.getElementById(g));f.draw(c,h)}else if($("#gvcc").attr("checked")){f=new google.visualization.ColumnChart(document.getElementById(g));f.draw(c,h)}else{f=new google.visualization.AreaChart(document.getElementById(g));f.draw(c,h)}}function setValidator(a){a.fadeIn("slow");a.css("z-index","999");a.css("font-size","10px");a.css("border-color","Black");a.css("background-color","LemonChiffon")}function setContextKey(a){if($find("fpac1")!=null)if(a=="ski"||a=="wswr")$find("fpac1").set_contextKey("ski");else if(a=="nl")$find("fpac1").set_contextKey("hlcity");else if(a=="ir")$find("fpac1").set_contextKey("eicity");else $find("fpac1").set_contextKey("uk")}$(document).ready(function(){var d="m",f="twopostcode",j=$.cookie(f),p=$.cookie("cbtab"),n=$.cookie("ddl"),h=" e.g London, W1 or W1 5BU";if(j!=null&&j!="")$("#fptbpc").val(unescape(j));else $("#fptbpc").val(h);if(p=="1"){$("#fpcbTab").attr("checked",true);$("#fpdbtns input").attr("disabled",true);$("#fpdbtns input").attr("disabled",true);$("#fpbtn1").attr("disabled",true);$("#btnDay7").attr("disabled",true)}else{$("#fpcbTab").attr("checked",false);$("#fpdbtns input").attr("disabled",false);$("#fpbtn1").attr("disabled",false);$("#btnDay7").attr("disabled",false)}n!=null&&$("#ddl").val(n);m($("#ddl").val());var a=$("#ddl").val(),c="http://www.theweatheroutlook.com/",b,o=c+"forecast/"+a+"/";$("#fptbpc").keyup(function(a){a.keyCode=="13"&&$("#btnDay16").click()});$("#btnDay7").click(function(){if($("#fptbpc").val()!=""&&$("#fptbpc").val().substr(0,1)!=" "){setCookie(f,$("#fptbpc").val());b=$("#fptbpc").val();window.location=c+"forecast/7day/"+b}else setValidator($("#err"),"Place or postcode required")});$("#btnDay16").click(function(){if($("#fptbpc").val()!=""&&$("#fptbpc").val()[0]!=" "){setCookie(f,$("#fptbpc").val());a=$("#ddl").val();b=$("#fptbpc").val();if($("#fpcbTab:checked").val()==undefined||$("#fpcbTab:checked").val()!=undefined&&(a!="uk"&&a!="ski"&&a!="nl"&&a!="ir")){$("#err").css("display","none");if(a=="uk"||a=="ski"||a=="nl"||a=="ir")window.location=c+"forecast/"+a+"/"+b;else if(a=="ukwr")window.location=c+"twoforecasts/for16day_risk.aspx?postcode="+b+"&selected=1";else if(a=="wswr")window.location=c+"twoforecasts/for16day_risk.aspx?postcode="+b+"&selected=3";else if(a=="as")window.location=c+"twoforecasts/forspecialist.aspx?postcode="+b+"&selected=3";else if(a=="cr")window.location=c+"twoforecasts/forindex.aspx?type=cricket&postcode="+b+"&selected=7";else if(a=="go")window.location=c+"twoforecasts/forindex.aspx?type=golf&postcode="+b+"&selected=8";else if(a=="fi")window.location=c+"twoforecasts/forindex.aspx?type=fishing&postcode="+b+"&selected=9";else if(a=="ga")window.location=c+"twoforecasts/forindex.aspx?type=gardening&postcode="+b+"&selected=10";else if(a=="ba")window.location=c+"twoforecasts/forindex.aspx?type=barbecue&postcode="+b+"&selected=11";else if(a=="te")window.location=c+"twoforecasts/forindex.aspx?type=barbecue&postcode="+b+"&selected=12";else if(a=="pa")window.location=c+"twoforecasts/forindex.aspx?type=walking&postcode="+b+"&selected=13";else if(a=="ukgr")window.location=c+"twodata/datmdlgraph.aspx?postcode="+b+"&selected=14"}else if($("#fpcbTab:checked").val()!=undefined)window.location=c+"forecasttab/"+b+"/2"}else setValidator($("#err"),"Place or postcode required")});$("#fpdbtns input,#fpbtn1").click(function(){if($("#fptbpc").val()!=""&&$("#fptbpc").val()[0]!=" "){setCookie(f,$("#fptbpc").val());var a=this.name;$("#fprun").val()=="3"||$("#fprun").val()=="6"||$("#fprun").val()=="9";window.location=o+$("#fptbpc").val()+"/"+a}else setValidator($("#err"),"Place or postcode required")});$("#ddl").bind("click keyup",function(){a=$("#ddl").val();m(a)});function m(a){if(a=="uk"||a=="ski"||a=="nl"||a=="ir"){$("#fpdbtns input").attr("disabled",false);$("#fpbtn1").attr("disabled",false);$("#btnDay7").attr("disabled",false)}else{$("#fpdbtns input").attr("disabled",true);$("#fpbtn1").attr("disabled",true);$("#btnDay7").attr("disabled",true)}setContextKey(a);$("#fpcbTab").attr("checked",false);setCookie("cbtab","0");setCookie("ddl",a)}$("#fpcbTab").click(function(){if($("#fpcbTab:checked").val()==undefined){setCookie("cbtab","0");$("#fpdbtns input").attr("disabled",false);$("#fpbtn1").attr("disabled",false);$("#btnDay7").attr("disabled",false)}else{setCookie("cbtab","1");$("#fpdbtns input").attr("disabled",true);$("#fpbtn1").attr("disabled",true);$("#btnDay7").attr("disabled",true)}});$("#fptbpc").click(function(){$("#err").css("display","none");$("#fptbpc").val()==h&&$("#fptbpc").val("")});$("#fptbpc").blur(function(){$("#fptbpc").val()==""&&$("#fptbpc").val(h)});$("#err").click(function(){$("#err").css("display","none")});var i="#d8d8d8",k=0;$(".tabhour td").each(function(){if($(this).text().trim()=="0")if(k==0){i="#e6eae8";k++}else{i="#d8d8d8";k=0}$(this).css("background-color",i)});l();$("#units input").change(function(){var b=$(this).attr("id"),a;if($("#wmph").attr("checked")!=false)a="m";else if($("#wkph").attr("checked")!=false)a="k";else a="n";if($("#tc").attr("checked")!=false)a=a+"c";else a=a+"f";setCookie("twounits",a);switch(b){case"wmph":e("m");break;case"wkph":e("k");break;case"wkts":e("n");break;case"tc":g("c");break;case"tf":g("f")}});$("#f16dp1, #itemPlaceholder a, #df a").click(function(){l()});function l(){var a=$.cookie("twounits");if(a!=null){if(a.substring(0,1)!="m")if(a.substring(0,1)=="k"){e("k");$("#wkph").attr("checked",true)}else{e("n");$("#wkts").attr("checked",true)}if(a.substring(1,2)!="c"){g("f");$("#tf").attr("checked",true)}}$("#wmph").attr("checked")=="undefined"&&e("k");$("#tc").attr("checked")=="undefined"&&g("f")}function g(a){$(".temp td,.temps, .wc").each(function(){$(this).toggle();if(a=="f"){if($(this).text().indexOf("C")>-1){var c=parseInt($(this).text().replace("\u00b0C",""))*9/5+32;$(this).text(Math.round(c)+" \u00b0F")}}else if($(this).text().indexOf("F")>-1){var b=(parseInt($(this).text().replace("\u00b0F",""))-32)/9*5;$(this).text(Math.round(b)+" \u00b0C")}$(this).toggle()});return}function e(a){$(".wind td,.winds").each(function(){if(a=="m"){if($(this).text().indexOf("mph")<0){var e;if(d=="k")e=parseInt($(this).text().replace("kph",""))/1.609;if(d=="n")e=parseInt($(this).text().replace("kts",""))*1.15;if(d=="m")b=parseInt($(this).text().replace("mph",""));$(this).text(Math.round(e)+" mph")}}else if(a=="k"){if($(this).text().indexOf("kph")<0){var c;if(d=="m")c=parseInt($(this).text().replace("mph",""))*1.609;if(d=="n")c=parseInt($(this).text().replace("mph",""))*1.852;if(d=="k")b=parseInt($(this).text().replace("kph",""));$(this).text(Math.round(c)+" kph")}}else if($(this).text().indexOf("kts")<0){var b;if(d=="m")b=parseInt($(this).text().replace("mph",""))*.87;if(d=="k")b=parseInt($(this).text().replace("mph",""))*.54;if(d=="n")b=parseInt($(this).text().replace("kts",""));$(this).text(Math.round(b)+" kts")}});d=a;return}})
