if(window.cbbc==undefined){cbbc={}}if(!cbbc.glowVersion){cbbc.glowVersion="0.3.1"}if(window.glow){glow.module("cbbc.utils.swf",cbbc.glowVersion,{require:["glow.dom"],implementation:function(){var D=/.swf($|\?)/i,B=[],C=glow.dom.get;var A=function(){};A.hasFlash=function(E,F){return A.getFlash(E||document,F).length>0},A.getFlash=function(E,G){E=E||document;var F=new glow.dom.NodeList();C("object, embed").each(function(){var H=this;if((H.getAttribute("type")=="application/x-shockwave-flash"||D.test(H.getAttribute("data")||H.getAttribute("src")||"")||(H.getAttribute("classid")||"").toLowerCase()=="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000")&&(G==null||!C(H).isWithin(G))){F.push([H])}});return F},A.hideFlash=function(E,G){if(B.length){return }var F=0;A.getFlash(E||document,G).each(function(){var H=this;B[F++]=[H,H.style.width,H.style.height,H.style.visibility];H.style.width="1px";H.style.height="1px";H.style.visibility="hidden"})},A.revertFlash=function(){for(var F=0,E=B.length;F<E;F++){B[F][0].style.height=B[F][2];B[F][0].style.width=B[F][1];B[F][0].style.visibility=B[F][3]}B=[]};return A}});glow.module("cbbc.widgets.utils",cbbc.glowVersion,{require:["glow.dom","glow.events"],implementation:function(){var C,B,A=glow.env;glow.ready(function(){C=document;B=C.body;var D=glow.dom.create('<div class="glow-cssTest"></div>').appendTo(B);if(D.css("z-index")!="1234"||D.css("background-image").indexOf("ctr.png")==-1){B.className+=" glow-basic"}D.remove();A.ie&&(B.className+=" glow-ie");(A.ie<7||!A.standardsMode)&&(B.className+=" glow-ielt7");A.gecko&&(B.className+=" glow-gecko")});return{_scrollPos:function(){var E=window,D=A.standardsMode?C.documentElement:B;return{x:D.scrollLeft||E.pageXOffset||0,y:D.scrollTop||E.pageYOffset||0}},_windowSize:function(){var D=0,E=0;if(typeof (window.innerWidth)=="number"){D=window.innerWidth;E=window.innerHeight}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){D=document.documentElement.clientWidth;E=document.documentElement.clientHeight}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){D=document.body.clientWidth;E=document.body.clientHeight}}}return{width:D,height:E}}}}});glow.module("cbbc.widgets.Mask",cbbc.glowVersion,{require:["glow.dom","glow.events","cbbc.widgets.utils"],implementation:function(){var F=glow.dom,G=F.get,H=glow.env,L=glow.events,I=cbbc.widgets.utils,D,A='<div class="glow-noMask" style="margin:0;padding:0;position:absolute;width:100%;top:0;left:0;overflow:auto;',B,K='<iframe class="glow-noMask" style="margin:0;padding:0;position:absolute;top:0;left:0;filter:alpha(opacity=0);display:none"></iframe>',J=cbbc.utils.swf,C=(navigator.platform.indexOf("Mac")!=-1&&(navigator.userAgent.indexOf("Firefox")!=-1||navigator.vendor.indexOf("Camino")!=-1));function E(R){this._isOpen=false;this.opts=glow.lang.apply({color:"#000",opacity:0.7,zIndex:9900,disableScroll:false,onlyOne:true},R||{});if(C){var S="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGDYBAAAtwCz7B/12wAAAABJRU5ErkJggg==";var N=document.createElement("canvas");if(!!N){N.width=N.height=1;var O=N.getContext("2d");if(!!O&&!!N.toDataURL){var T=F.parseCssColor(this.opts.color);O.fillStyle="rgba("+T.r+", "+T.g+", "+T.b+", "+this.opts.opacity+")";O.fillRect(0,0,1,1);S=N.toDataURL("image/png")}}this.opts.color="url("+S+")";this.opts.opacity=1}var P=document.body,M=this.maskElement=F.create(A+"z-index:"+this.opts.zIndex+";background:"+this.opts.color+';visibility:hidden"></div>').appendTo(P),Q=this;if(!!this.opts.loading){this.loading=this.opts.loading.css("position","absolute").css("z-index",this.opts.zIndex+1).css("display","none").appendTo(P)}M.css("opacity",this.opts.opacity);if(glow.env.ie<7){this._iframe=F.create(K).css("z-index",this.opts.zIndex-1).appendTo(P)}L.addListener(M,"click",function(){L.fire(Q,"click")});if(this.opts.onClick){L.addListener(this,"click",R.onClick)}}E.prototype={hideLoading:function(){this.loading.css("display","none")},showLoading:function(){this.loading.css("display","block")},add:function(P){if(this._isOpen){return }var S=G(document),M=G(document.body),R=cbbc.widgets.utils._windowSize(),Q=this;L.fire(cbbc.widgets.Mask,"open");this._isOpen=true;function O(){var W=M.height(),T=M.width();for(var U=0;U<2;U++){Q.maskElement.css("width","100%").css("height",Math.max(W,R.height)+"px")}if(!!Q.loading){N()}if(glow.env.ie<7){var V=Q.maskElement[0].style;Q._iframe.css("width",V.width).css("height",V.height)}}function N(){var T=(!H.ie&&!(H.webkit<522))||(H.ie>6&&H.standardsMode),U=T?{x:0,y:0}:I._scrollPos();if(T){Q.loading.css("position","fixed")}Q.loading.css("top",(R.height-Q.loading.height())/2+U.y+"px");Q.loading.css("left",(R.width-Q.loading.width())/2+U.x+"px")}J.hideFlash(document);this.maskElement.css("visibility","visible");this.maskElement.css("display","block");if(P){this.showLoading()}if(glow.env.ie<7){this._iframe.css("display","block")}O();this._resizeListener=L.addListener(window,"resize",O);this._scrollListener=L.addListener(window,"scroll",N)},remove:function(){if(!this._isOpen){return }this._isOpen=false;if(!!this.loading){this.hideLoading()}this.maskElement.css("visibility","hidden");this.maskElement.css("display","none");if(glow.env.ie<7){this._iframe.css("display","none")}L.removeListener(this._resizeListener);L.removeListener(this._scrollListener);J.revertFlash();L.fire(cbbc.widgets.Mask,"close")}};return E}})}cbbc.lbstub=function(){var lbScriptUrl="/cbbc/script/cbbc.lb.js",sections={home:"/cbbc/",create:"/cbbc/create/",find:"/cbbc/find/",grab:"/cbbc/grab/",games:"/cbbc/games/",watch:"/cbbc/watch/",connect:"/cbbc/connect/",help:"/cbbc/help/"};var isSupported=(function(){var ua=navigator.userAgent.toLowerCase(),nanArray=[0,NaN],opera=Number((/opera[\s\/]([\d\.]+)/.exec(ua)||nanArray)[1]),ie=opera?NaN:Number((/msie ([\d\.]+)/.exec(ua)||nanArray)[1]);if(window.glow){if(!glow.isSupported){return false}}if(window.XMLHttpRequest){return true}else{if(ie<7){var progIds=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP"];for(var i=0,len=progIds.length;i<len;i++){try{new ActiveXObject(progIds[i]);return true}catch(e){}}}}return false})();var fail=function(url){url=[url,(url.indexOf("?")>=0?"&":"?"),"lb_fail=1"].join("");window.location.assign(url)};var R={};var isWindowLoaded=false;if(!isSupported){R={isSupported:false,redirect:function(){},launchClickListener:function(){},launchOrRedirect:fail};if(!cbbc.lb){cbbc.lb=cbbc.lbstub}return R}var init=function(){var css=[".glow-cssTest {","background: url('//www.bbc.co.uk/glow/"+cbbc.glowVersion+"/dist/widgets/images/darkpanel/ctr.png');","position: absolute;","visibility: hidden;","z-index: 1234;","}",".glow-overlay {","	visibility: hidden;","	display: none;","	overflow: hidden;","	position: absolute;","}"].join("");R.addStyleSheet(css);if(window.location.hash){var loadLbNow=function(){var hash=window.location.hash;if(hash.indexOf("#")===0){hash=hash.substring(1)}var url="/cbbc"+hash;R.launch(url)};if(isWindowLoaded){loadLbNow()}else{glow.events.addListener(window,"load",loadLbNow)}}};R={isSupported:true,mask:null,redirect:function(launchUrl,contentPath){var query=(!!window.location.search)?window.location.search:"";if(query.indexOf("dbg=1")>=0||query.indexOf("lb_fail=1")>=0){return }window.location=launchUrl+query+"#/lb/"+contentPath},addStyleSheet:function(css){var elem=document.createElement("style");document.getElementsByTagName("head")[0].appendChild(elem);if(!!elem.styleSheet){elem.styleSheet.cssText=css}else{var textNode=document.createTextNode(css);elem.appendChild(textNode)}return elem},addHandlersToAllAnchors:function(){var anchors=document.getElementsByTagName("a");for(var i=0;i<anchors.length;i++){if(anchors[i].onclick){anchors[i]._overridenOnclick=anchors[i].onclick}if(anchors[i].href&&anchors[i].href!="#"){anchors[i].onclick=function(e){var ret=true;if(this._overridenOnclick){ret=this._overridenOnclick.apply(this,[e])}return !R.launch(this.href)&&ret}}}},splitUrlToParts:function(sourceUri){var uriPartNames=["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"],uriParts=new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri),uri={};for(var i=0;i<10;i++){uri[uriPartNames[i]]=(uriParts[i]?uriParts[i]:"")}if(uri.directoryPath.length>0){uri.directoryPath=uri.directoryPath.replace(/\/?$/,"/")}return uri},getDataFromUrl:function(url){var re=[/\/cbbc\/lb\/([^?#\n\s]+)(.*)/,/\/cbbc\/([^?]*)\/lb\/([^?#\n\s]+)(.*)/],urlParts=R.splitUrlToParts(url),obj,match;for(var i=0;i<re.length;i++){match=re[i].exec(url);if(!!match){obj={section:(i==0)?null:match[1],lbPath:(i==0)?match[1]:match[2]};obj.path="/cbbc/";if(i!=0){obj.path+=match[1]+"/"}if(!sections[obj.section]){if(!obj.lbPath){obj.lbPath=obj.section}match=/([^\/]+)\/(.*)/.exec(obj.section);if(!!match){if(sections[match[1]]){obj.section=match[1];obj.lbPath="games/lb/"+obj.lbPath;break}}obj.section="*"}else{obj.lbPath=obj.section+"/"+obj.lbPath}obj.lbPath="/lb/"+obj.lbPath;obj.query=urlParts.query;break}}return obj},launchOrRedirect:function(url){if(url.constructor==Array){url=url[0]}if(url.constructor==Array){url=url[0]}if(!R.launch(url)){window.location.assign(url)}return true},launchClickListener:function(e){var el=glow.dom.get(e.source);while(!!el.parent()&&!el.is("a")){el=el.parent()}if(el.is("a")){if(el.hasAttr("href")&&R.launch(el.attr("href"))){e.preventDefault()}}},fail:fail,launch:function(url){if(url.indexOf("/cbbc/radioplayer")>-1){window.open(url,"winPopup","width=660,height=390,left=0,top=0,screenX=0,screenY=0");return true}var o=R.getDataFromUrl(url);if(!o){return false}try{if(!cbbc.section||(o.section!="*"&&o.section!=cbbc.section)){var redirect=o.path+"#"+o.lbPath;window.location=redirect;return true}if(!cbbc.lb.isLoaded){R.mask=new cbbc.widgets.Mask({loading:glow.dom.create("<img src='/cbbc/img/f/lb/loading.png' width='127' height='47' />")});R.mask.add(true);glow.net.loadScript(lbScriptUrl);R.executeWhenLoaded(R.launch,null,[url],"cbbc.lb.isLoaded");return true}cbbc.lb.launch(url)}catch(e){R.fail(url)}return true},executeWhenLoaded:function(func,funcScope,funcArgs){var intRef,argRef=arguments;function executeCheck(){for(var i=3;i<argRef.length;i++){var test=false;eval("test = window."+argRef[i]);if(!test){if(!intRef){intRef=setInterval(executeCheck,50)}return }}clearInterval(intRef);func.apply(funcScope,funcArgs)}executeCheck()}};if(window.glow){glow.events.addListener(window,"load",function(){isWindowLoaded=true});glow.ready(init)}if(window.blqOnDomReady){blqOnDomReady(function(){R.addHandlersToAllAnchors()})}if(!cbbc.lb){cbbc.lb=R}return R};if(!window.glow){cbbc.lbstub=cbbc.lbstub()}else{glow.module("cbbc.lbstub",cbbc.glowVersion,{require:[],implementation:cbbc.lbstub})};