(function(){var I,G,X,S=null,A={},U={searchSuggestion:"Search the BBC"},J=31536000000,H={updateNoImagesState:function(){var Y=G("#blq-search-btn")[0];if(Y.currentStyle){var Z=Y.currentStyle.backgroundImage}else{if(window.getComputedStyle){var Z=document.defaultView.getComputedStyle(Y,null).getPropertyValue("background-image")}}if(Z.indexOf("search_icon.png")==-1){return false}else{G("#blq-mast-home").removeClass("blq-no-images");return true}},searchTheBBCSearchHint:function(){var Y=G("#blq-search");X(Y,"focus",function(){if(Y.val()==U.searchSuggestion){Y.val("")}});X(Y,"blur",function(){if(!Y.val()){Y.val(U.searchSuggestion)}});X(Y.parent().parent(),"submit",function(Z){if(Y.val()==U.searchSuggestion){Y.val("")}});if(Y.val()==""&&!G(document.activeElement).eq(Y)){Y.val(U.searchSuggestion)}},addMorePanel:function(){var Z=G("#blq-nav-links"),b=G("#blq-nav-main");Z.css({visibility:"hidden",display:"block"});var Y=G("body"),a=new I.widgets.Panel(G("#blq-nav-links"),{modal:false,hideWindowedFlash:false,width:Z.width(),height:Z.height(),template:'<div><div class="panel-hd"></div><div class="panel-bd"></div><div class="panel-ft"></div></div>',autoPosition:false,id:"blq-morepanel"}),d,c=function(){a.hide();b.removeClass("blq-morepanel-shown");unbind(d);return false},f=function(){if(a.isShown){return false}a.show();b.addClass("blq-morepanel-shown");setTimeout(function(){d=X(document,"click",e)},0);return false};Z.css({visibility:""});a.container.addClass("blq-overlay").addClass("blq-gvl-3").addClass("blq-rst").appendTo("#blq-container-inner");X("#blq-nav-m a","click",f);function e(g){if(g.source!=a.container[0]&&!G(g.source).isWithin(a.container)){c()}}},mapPublicApi:function(){if(!window.blqOnDomReady){window.blqOnDomReady=I.ready}},addAutosuggest:function(){var Y=this;if(!blq.suggest){blq.suggest=function(Z){if(Y.suggestion&&Y.suggestion._pendingRequest){clearTimeout(Y.suggestion._pendingRequest._timeout)}Y.suggestion._pendingRequest=null;Y.suggestion.setData(Z[1]||[]);Y.suggestion.find();I.dom.get("#blq-search-btn").removeClass("loading")}}I.ready(function(){var Z=document.getElementById("blq-search");if(!Z){return false}Z.setAttribute("autocomplete","off");Z.onfocus=function(){if(document.getElementById("blq-autosuggest")){return false}gloader.load(["glow","1","glow.dom","glow.net","glow.widgets.AutoSuggest"],{async:true,onLoad:function(a){a.ready(function(){var d=a.dom.get;var c=d("#blq-mast input").filter(function(e){return d(this).attr("name")=="scope"});c=(c.length)?c.attr("value"):"all";Y.noData=false;var b=a.dom.get("#blq-container-inner").hasClass("blq-rtl");Y.suggestion=new a.widgets.AutoSuggest("#blq-search",[],{index:"title",maxListLength:blq.suggest_short?3:6,activeOnShow:false,useCache:true,formatItem:function(f){var e=f.title;if(e.length>28){e=f.title.substring(0,25)+"...";e+='<span class="blq-hide">'+f.title.substring(25,f.title.length)+"</span>"}return e},isMatch:function(){return this.data.length?true:false},onInputChange:function(g){g.preventDefault();if(this.noData){return false}a.dom.get("#suggid").remove();if(this._pendingRequest){this._pendingRequest.abort()}var f=this;var e=a.data.encodeUrl({q:g.value,scope:c,format:"blq-1",callback:"blq.suggest"});this._pendingRequest=a.net.loadScript(this.searchHost+"/suggest?"+e,{useCache:true,charset:"utf-8",onError:function(){f.inputElement.attr("autocomplete","on");f.noData=true},timeout:5});a.dom.get("#blq-search-btn").addClass("loading")},onDataError:function(e){this.inputElement.attr("autocomplete","on")},onItemSelect:function(g){this.setValue(g.selectedItem.title);var e=a.dom.get("#suggid");if(!e.length){e=a.dom.create('<input type="hidden" name="suggid" id="suggid" />');a.dom.get("#blq-mast form").prepend(e)}e.val(g.selectedItem.id);var f=a.dom.get("#blq-mast form");f[0].submit()}});Y.suggestion.searchHost=Y.searchHost||"http://search.bbc.co.uk";Y.suggestion.overlay.container.attr("id","blq-autosuggest");Y.suggestion.overlay.container.addClass("blq-rst");if(b){Y.suggestion.overlay.container.addClass("blq-rtl")}Y.suggestion.overlay.opts.hideWindowedFlash=false;a.events.addListener(Y.suggestion,"show",function(){a.dom.get("#blq-search-btn").removeClass("loading")})})}});Z.onfocus=function(){}}})},setARIAValues:function(){G("#blq-acc").attr("role","navigation");G("#blq-search").attr("role","search");G("#blq-local-nav").attr("role","navigation");G("#blq-content").attr("role","main");G("#blq-nav-main").attr("role","navigation");G("#blq-nav").attr("role","navigation");G("#blq-foot").attr("role","contentinfo")},defaultGoTracking:function(){F("blq-acc",{go:"{id}3/{dir}"});F("blq-mast",{go:"{id}3/{dir}"});F("blq-nav",{go:"{id}3/{dir}"});F("blq-disclaim",{go:"{id}3/{dir}"});F("blq-sitelinks",{go:"{id}3/{count}/{dir}"});F("blq-bbclinks",{go:"{id}3/{dir}"});F("blq-nav-links",{go:"{id}3/{dir}"});F("blq-main",{external:true});if(blq.externalGoTrackingConfig){for(var a in blq.externalGoTrackingConfig){var Z=blq.externalGoTrackingConfig[a];var Y=I.dom.get(a);if(Y.length){F(Y,{go:Z,external:true})}}}},createClickHandlersForMobileLinks:function(){var Z=document.getElementById("blq-acc-mobile-link"),Y=document.getElementById("blq-acc-desktop");if(Y){Y.onclick=function(a){P("desktop")}}else{if(Z){Z.onclick=function(a){P("mobile")}}}}};function D(){return(document.getElementById&&document.getElementsByTagName)}function F(b,m){var b=document.getElementById(b)||b,m=m||{},c=b.nodeName=="A"?[b]:b.length?b:b.getElementsByTagName("a"),q=m.external||false,o=m.path||window.location.toString().split("bbc.co.uk/")[1],k=b.id?b.id.replace(/-/g,"/"):"_auto",h=m.go||"{path}/int/{id}/{dir}",s=m.currentServer||window.location.href.split("//")[1].split("/")[0];for(var t=0;t<c.length;t++){var d=false,u=false;if((typeof c[t]!="object")||(!c[t].href)||c[t].className.indexOf("blq-nogo")!=-1||c[t].href.indexOf("/go/")!=-1||c[t].href.charAt(0)=="#"||c[t].href.charAt(window.location.toString().split("#")[0].length)=="#"||c[t].href.indexOf("mailto:")==0||c[t].href.indexOf("javascript:")==0||c[t].href.indexOf("itpc:")==0||c[t].href.indexOf("zune:")==0||c[t].href.indexOf("zcast:")==0){continue}if(c[t].href.indexOf("bbc.co.uk")!=-1&&c[t].href.indexOf("#")!=-1){if(c[t].href.indexOf(o+"#")!=-1){continue}}var j=s.replace(/\./g,"\\."),p=c[t].href.split("?")[0],r=new RegExp("^[A-Za-z]+:\\/\\/(?:[^.]+\\.)*(?:bbc\\.co\\.uk|doubleclick\\.net|"+j+")");if(!r.test(p)){if(m.go){var n=p.split("/")[2],d=true,Z="/"+h.replace("{dir}",n).replace("{count}",t+1).replace("{path}",o).replace("{id}",k).replace("#","_")}else{var e=location.pathname,d=true,Z=e+(e.charAt(e.length-1)=="/"?"":"/")+"ext/_auto"}}else{if(q){continue}else{var l=p.split("/"),Z=h,Y=l.length<5?l[l.length-1]||l[l.length-2]:l[l.length-2]||l[l.length-1];Z=Z.replace("{dir}",Y);Z=Z.replace("{count}",t+1);Z=Z.replace("{path}",o);Z=Z.replace("{id}",k);Z=Z.replace("#","_");Z="/"+Z}}var f=c[t].onclick,g,a=false;if(p.indexOf("www.bbc.co.uk")!=-1){g="http://www.bbc.co.uk/go"+Z+"/-/"+c[t].href.substring(c[t].href.indexOf("bbc.co.uk/")+10,c[t].href.length)}else{if(c[t].href.indexOf("www.bbc.com")!=-1){g="http://www.bbc.com/go"+Z+"/-/"+c[t].href.substring(c[t].href.indexOf("http://www.bbc.com/"),c[t].href.length)}else{if(d||c[t].href.indexOf(s)==-1){g="/go"+Z+"/-/"+c[t].href}else{g="/go"+Z+"/-/"+c[t].href.substring(c[t].href.indexOf(s)+(s.length+1),c[t].href.length)}}}if(!c[t].blqGoTrackingHref){c[t].onclick=(function(){var i=f;return function(){this.href=this.blqGoTrackingHref;if(typeof i=="function"){i()}}})()}c[t].blqGoTrackingHref=g}}function C(Y){if(L[Y]){delete L[Y]}if(Y=="addGoTrack"||Y=="defaultGoTracking"){L.addGoTrack=function(){};L.addGoTrack.isStub=true}}function O(a,c,b){var Z=new Date(),Y;Z.setTime(Z.getTime()+b);Y="; expires="+Z.toGMTString();document.cookie=a+"="+encodeURIComponent(c)+Y+"; path=/"}function P(Z,Y){if(!Y){Y=J}switch(Z){case"mobile":O("blq.dPref","m",Y);break;case"desktop":O("blq.dPref","d",Y);break;default:throw"No device has been set";break}}function K(){var Y=B("blq.dPref");if(Y){return Y}else{return false}}function B(a){var d=a+"=",c=document.cookie.split(";"),Z;for(var b=0,Y=c.length;b<Y;b++){Z=c[b];while(Z.charAt(0)===" "){Z=Z.substring(1,Z.length)}if(Z.indexOf(d)===0){return decodeURIComponent(Z.substring(d.length,Z.length))}}return null}function W(Y){O(Y,"",-1)}function V(){return S}function M(Y){S=Y}function N(Y){return A[Y]}function R(Y,Z){A[Y]=Z}function T(Y,Z){U[Y]=Z}function E(a,Y){if(a.createTextRange){var Z=a.createTextRange();Z.moveStart("character",Y);Z.moveEnd("character",Y-a.value.length);Z.select()}else{if(a.selectionStart){a.focus();a.setSelectionRange(Y,Y)}else{a.focus()}}}function Q(Z){if(D()){I=Z,G=Z.dom.get,X=Z.events.addListener;unbind=Z.events.removeListener;for(var Y in L){L[Y]()}}}var L=(function(){return H})();window.blq={addGoTrack:F,disableFeature:C,environment:V,setEnvironment:M,setLabel:T,flagpole:N,setFlagpole:R,createCookie:O,readCookie:B,eraseCookie:W,setDevicePref:P,getDevicePref:K,availableFeatures:L};if(window.gloader){document.documentElement.className+=" blq-js";gloader.load(["glow","1","glow.dom","glow.widgets.Panel"],{async:true,onLoad:function(Y){Y.ready(function(){Q(Y)})}})}})();var demi=(function(){var C=false,B=[],A=null;return{_reset:function(){C=false;B=[];A=null},_loaded:function(){while(B.length>0){demi.getDevice(B.shift(),blq.environment())}},_addScriptTag:function(F){var D=document.getElementsByTagName("head")[0];var E=document.createElement("script");E.type="text/javascript";E.src=F;D.insertBefore(E,D.firstChild)},_setSource:function(D){A=D},getDevice:function(D){B.push(D);if(!C){C=true;demi._addScriptTag(A)}}}})();
