(function(){if(typeof window.locator=="object"){return;}var u,p,k,n,D,w={};gloader.load(["glow","1","glow.dom","glow.events","glow.net","glow.i18n"],{onLoad:function(I){u=I;p=u.events;k=u.net;n=u.lang;D=u.i18n;u.ready(function(){w.cookie=b();});w.locales=LocalesNS=w.locales||{};LocalesNS.msg="LocatorMessages";D.addLocaleModule(LocalesNS.msg,"en",{help:{title:"My Location Help",body:"The My Location feature takes a location of your choice and uses it to display relevant information on the BBC News and Weather websites. You only need to set it in one place and the information is automatically shared."},fromWeather:{title:"We Remembered",body:"We remembered your location from the BBC News site"},fromNews:{title:"We Remembered",body:"We remembered your location from the BBC Weather site"}});}});var z="MYLOC",C=".bbc.co.uk",c="365",v=2,i="@",A="|",y="~";var E=false;var m=4;var g={A:"WCW",B:"WID",C:"LOCATOR"};var d="http://news.bbc.co.uk",h="/weather/util/search/WeatherSuggestJSON",H="/weather/util/search/WeatherSearch";var f=d+h+".{format}?region={region}&search={search}&jsoncallback={callback}",q=d+H+".{format}?region={region}&search={search}&jsoncallback={callback}",l=d+H+".{format}?region={region}&lat={lat}&lon={lon}&radius={radius}&jsoncallback={callback}",e={format:"json",region:"world",search:""};var j=function(I,J){if(!J){return;}k.loadScript(I,{onLoad:function(K){J(K);}});};var t=function(I){return g[I];};var s=function(J){for(var I in g){if(g[I]==J){return I;}}return null;};var r=function(J,K){for(var L=0,I=J.length;L<I;L++){if(J[L]&&J[L].name==K){return L;}}return null;};var x=function(I,J){var K=r(I,J);if(K!=null){return I[K];}else{return null;}};var F=function(I,K){var J=x(I,K);if(!J&&G(K)){J={name:K,value:""};I.push(J);}return J;};var G=function(I){return !!s(I);};var a=function(I,J){var K=r(I,J);if(K!=null){delete I[K];}};var B=function(K,I){var I=I||{},R=[],O="",J;if(!w.shouldWriteToCookie()){return;}for(var L=0,M=K.dataStores.length;L<M;L++){var Q=K.dataStores[L];if(Q!=null&&Q.name!=null&&Q.value!=null){var P=s(Q.name),S=encodeURI(Q.value),N=P+S;R.push(N);}}O=R.join(A);J=[v,O].join(i);w.util.Cookie.create(z,J,c,C);};var b=function(){var I=w.util.Cookie.read(z),J={dataStores:[]},V,R,K,O,N;if(typeof I==="string"){V=I.split(i);try{R=parseInt(V[0])?parseInt(V[0]):null;O=V[1];if(R){J.version=R;}else{o();}if(O){N=O.split(A);for(var P=0,Q=N.length;P<Q;P++){var U=N[P],T=U.charAt(0),S=t(T),L=decodeURI(U.slice(1));J.dataStores.push({name:S,value:L});}}else{o();}}catch(M){o();}}return J;};var o=function(){w.util.Cookie.destroy(z,C);};w={locales:{},EVENTS:{locationChanged:"locationChanged",autoSuggestSelected:"autoSuggestSelected",userShownLocationChange:"userShownLocationChange",userConfirmedLocationChange:"userConfirmedLocationChange",userCancelledLocationChange:"userCancelledLocationChange",userShownClearLocation:"userShownClearLocation",userConfirmedClearLocation:"userConfirmedClearLocation",userCancelledClearLocation:"userCancelledClearLocation"},cookie:{version:null,dataStores:[]},migrate:function(){},on:function(I,J){return p.addListener(this,I,J);},getSharedLocationId:function(){this.cookie=b();var I=x(this.cookie.dataStores,"WCW");if(!this.COOKIE_EXTENDED&&I){B(this.cookie);this.COOKIE_EXTENDED=true;}if(I){return I.value;}return null;},isIdValid:function(K){var J=true;if(J&&K=="undefined"){J=false;}if(J&&(K==undefined||K==null)){J=false;}if(J&&K.split){var I=K.split(y);J=(I.length==m)?true:false;}return J;},setSharedLocationId:function(L,J){var J=J||{};if(L instanceof locator.Location){L=L.toString();}if(!this.isIdValid(L)||!this.shouldWriteToCookie()){return;}var K=F(this.cookie.dataStores,"WCW");K.value=L;var I=x(this.cookie.dataStores,"WID");if(I){a(this.cookie.dataStores,"WID");}B(this.cookie);if(J._beforeEvent){J._beforeEvent();}p.fire(this,this.EVENTS.locationChanged,{locationId:L});},clearSharedLocation:function(){if(!this.shouldWriteToCookie()){return;}w.util.Cookie.destroy(z,C);p.fire(this,this.EVENTS.locationChanged,{locationId:null});},hasSharedLocationIdChanged:function(I){return !!getSavedLocation()==I;},shouldWriteToCookie:function(){var J=(this.cookie.version?this.cookie.version:v),I=v;return !!(J<=I);},getMessageForId:function(I){var J=D.getLocaleModule(locator.locales.msg);return J[I]?J[I]:null;},getMessagesForClient:function(I){var J=[];switch(I){case"newshp":if(this.cookie.version==1){J.push("fromWeather");}break;case"weather":if(this.cookie.version==2){J.push("fromNews");}break;}return J;},searchByPlaceName:function(L,Q,I){var I=I||{},O=I.searchType||"full",P=I.startIndex||null,N=I.type||null,K=n.apply(e,I),J,M;K.search=L;if(O=="suggest"){J=n.interpolate(f,K);}else{J=n.interpolate(q,K);}if(P){J+="&startIndex="+P;}if(N){J+="&type="+N;}j(J,Q);},searchByCoordinatesWithRadius:function(N,M,I,O,L){var K=u.lang.apply(e,{lon:N,lat:M,radius:I}),J=n.interpolate(l,K);if(!O){return;}j(J,O);},searchByPostcode:function(J,M,L){var K=u.lang.apply(e,{search:encodeURIComponent(J)}),I=n.interpolate(q,K);if(!M){return;}j(I,function(O){var N=null;if(O.results&&O.results[0]){N=O.results[0];}M(N);});},fetchFromDataSet:function(N,P,L){this.migrate();if(!N){return null;}if(L=="wcw"){var O=x(this.cookie.dataStores,"WCW");var K=(O&&O.value)?O.value.split(y):[null,null,null,null];P({id:K[0],name:K[1],isNearest:K[2],nationId:K[3]});}else{if(L=="wid"){var J=x(this.cookie.dataStores,"WID"),M={id:null,alt:null};if(J&&J.value){var I=(J&&J.value)?J.value.split(y):[null,null];M={id:(I[0]?I[0]:null),alt:(I[1]?I[1]:null)};}P(M);}else{throw Error("Data Set not supported");}}},_setDataSet:function(J,K){if(!this.shouldWriteToCookie()){return;}var I=F(this.cookie.dataStores,J);I.value=K;B(this.cookie);},_setLegacyCookieVersion:function(I){v=I;}};w.Location=(function(){var I=function(M,J,L,K){this.id=M;this.name=J;if(L==1){this.isNearest=true;}else{this.isNearest=false;}this.nationId=K;};I.DELIM=y;I.parse=function(K){var L=K.split(I.DELIM),O=L[0],J=L[1],N=L[2],M=L[3];return new I(O,J,N,M);};I.prototype={toString:function(){var J=[this.id,this.name,(this.isNearest?"1":"0"),this.nationId];return J.join(I.DELIM);}};return I;})();if(!window.locator){window.locator=w;}})();(function(){var a={create:function(d,g,h,f){var e="";if(h){var c=new Date();c.setTime(c.getTime()+(h*24*60*60*1000));var b="; expires="+c.toGMTString();}else{var b="";}e=d+"="+g+b+"; path=/";if(f){e+="; domain="+f;}document.cookie=e;},read:function(d){var f=d+"=";var b=document.cookie.split(";");for(var e=0;e<b.length;e++){var g=b[e];while(g.charAt(0)==" "){g=g.substring(1,g.length);}if(g.indexOf(f)==0){return g.substring(f.length,g.length);}}return null;},destroy:function(b,c){a.create(b,"",-1,c);}};if(typeof window.locator=="object"&&typeof window.locator.util!="object"){window.locator.util={Cookie:a,bind:function(b,c){return function(){c.apply(b,arguments);};}};}})();
