if(window.cbb==undefined){cbb={}}(function(){cbb.site={navMain:null,navShows:null,init:function(){cbb.site.keyboardListener.init();cbb.site.guInfo.init();cbb.site.toggleSound.init();cbb.site.embed.nav();cbb.site.embed.shows();cbb.site.embed.flashBrandArea();cbb.site.interstitial.init()},readCookie:function(B){var D=B+"=";var A=document.cookie.split(";");var E;for(var C=0;C<A.length;C++){E=A[C];while(E.charAt(0)==" "){E=E.substring(1,E.length)}if(E.indexOf(D)==0){return E.substring(D.length,E.length)}}return null},writeCookie:function(C,D,E){if(E){var B=new Date();B.setTime(B.getTime()+(E*24*60*60*1000));var A="; expires="+B.toGMTString()}else{var A=""}document.cookie=C+"="+D+A+"; path=/"},eraseCookie:function(A){writeCookie(A,"",-1)}};cbb.site.keyboardListener={shiftPressed:false,tabPressed:false,tabbableItems:[],init:function(){shiftPressed=false,tabPressed=false,tabbableItems=[],document.onkeydown=cbb.site.keyboardListener.keyDownHandler;document.onkeyup=cbb.site.keyboardListener.keyUpHandler;window.document.getElementById("a-cbeebies-logo").onfocus=cbb.site.keyboardListener.logoGotFocus;window.document.getElementById("a-cbeebies-logo").onblur=cbb.site.keyboardListener.logoLostFocus},addTabbableItem:function(A){tabbableItems[A.key]=A.id},keyDownHandler:function(B){var A=B||window.event;if(A.keyCode==9){tabPressed=true}else{if(A.keyCode==16){shiftPressed=true}}},keyUpHandler:function(B){var A=B||window.event;if(A.keyCode==9){tabPressed=false}else{if(A.keyCode==16){shiftPressed=false}}},logoGotFocus:function(){},logoLostFocus:function(){if(!shiftPressed){document.getElementById(tabbableItems.navmain).focus()}},navmainLostFocus:function(A){if(!A){document.getElementById("a-cbeebies-logo").focus()}else{document.getElementById(tabbableItems.navshows).focus()}},navshowsLostFocus:function(A){if(!A){document.getElementById(tabbableItems.navmain).focus()}else{var B=document.getElementById("cbb-mainpromo-swf");if(B!=null){B.focus()}else{document.getElementById(tabbableItems.navshows).blur()}}},hpPromoLostFocus:function(A){if(!A){document.getElementById(tabbableItems.navshows).focus()}else{var B=document.getElementById("cbb-mainpromo-swf");if(B!=null){B.blur()}}}};cbb.site.embed={dateTime:function(){var A=new Date();var H=A.getDate();var J=(H<10)?"0"+H:H;var B=A.getMonth()+1;var D=(B<10)?"0"+B:B;var I=A.getFullYear()-2000;var G=(I<10)?"0"+I:I;var F=A.getHours();var C=(F<10)?"0"+F:F;var E=A.getMinutes();var D=(E<10)?"0"+E:E;var M=A.getSeconds();var L=(M<10)?"0"+M:M;var K=J+"/"+D+"/"+G+" "+C+":"+D+":"+L;return K},nav:function(D,E){if(!D){D="/cbeebies/swf/navbar/"}if(!E){E="/cbeebies/swf/navbar/"}var C;for(var A=0;A<cbb.sections.length;A++){if(cbb.sections[A].section==cbb.section){C=A}}var B={width:"100%",height:"150",attributes:{id:"cbb-banner-swf",name:"cbb-banner-swf"},params:{seamlesstabbing:"false",allowscriptaccess:"always",scale:"noscale",flashVars:{d:cbb.site.embed.dateTime(),secid:C,xmlpath:D,base:E,soundenabled:cbb.site.toggleSound.getSound()}},message:function(){return glow.dom.get("#cbb-banner-embed").html()}};cbb.site.navMain=new glow.embed.Flash("/cbeebies/swf/navbar/preloader.swf","#cbb-banner-embed","9",B).embed();cbb.site.keyboardListener.addTabbableItem({key:"navmain",id:B.attributes.id})},shows:function(D,E){if(!D){D="/cbeebies/swf/navbar/xml/"}if(!E){E="/cbeebies/swf/navbar/"}var C;for(var A=0;A<cbb.sections.length;A++){if(cbb.sections[A].section==cbb.section){C=A}}var B={width:"100%",height:"100%",attributes:{id:"cbb-shows-swf",name:"cbb-shows-swf"},params:{allowscriptaccess:"always",seamlesstabbing:"false",flashVars:{d:cbb.site.embed.dateTime(),secid:C,xmlpath:D,base:E,soundenabled:cbb.site.toggleSound.getSound()}},message:function(){return glow.dom.get("#cbb-nav-shows").html()}};cbb.site.navShows=new glow.embed.Flash("/cbeebies/swf/navbar/preloaderShows.swf","#cbb-nav-shows","9",B).embed();cbb.site.keyboardListener.addTabbableItem({key:"navshows",id:B.attributes.id})},flashBrandArea:function(){if(glow.dom.get("#cbb-flashsplash").length==0){return }if(!window.flashConfig){return }var D=(flashConfig.width)?flashConfig.width:"734";var B=(flashConfig.height)?flashConfig.height:"302";var A=(flashConfig.params)?flashConfig.params:{};var C={width:D,height:B,attributes:{id:"cbb-flashsplash-swf",name:"cbb-flashsplash-swf",bgcolor:"#EAEAEA"},params:A,message:function(){cbb.site.embed.flashMsg()}};new glow.embed.Flash(flashConfig.src,"#cbb-flashsplash",flashConfig.version,C).embed();glow.dom.get("#cbb-flashsplash").css("visibility","visible")},flashBrandAreaReady:function(){glow.dom.get("#cbb-flashsplash").css("visibility","visible")},flashMsg:function(){var A=glow.dom.get("#cbb-flashsplash");glow.dom.get(A.get(".cbb-text-overlay p")[0]).empty().text("You do not have the correct Flash Player to see this.");return A.html()}};cbb.site.interstitial={iPlayerPanel:null,showThis:true,init:function(){var C=cbb.site.readCookie("cbb-iplayer-msg");if(!C|C=="true"){cbb.site.interstitial.showThis=true}else{cbb.site.interstitial.showThis=false}var A=(!cbb.site.interstitial.showThis)?"checked='checked'":"";var E=glow.dom.get(".cbb-iplayer-link");var B=glow.dom.create("<div id='iPlayerPanel'><h2>You are about to go to CBeebies iPlayer<span><!-- --></span></h2><p>The CBeebies iPlayer is designed to put parents more in control of your family's viewing - allowing you to schedule your favourite shows online when it suits you.<p><a href='#' id='iplayer_no'> Back to Cbeebies<span><!-- --></span></a><a href='#' id='iplayer_yes'>CBeebies iPlayer<span><!-- --></span></a></p><form><p><input type='checkbox'"+A+" name='show-again' id='show-again' /> Do not show me this again</p></form><p class='grownups-link'><a href='/cbeebies/grownups/about/cbeebies_iplayer.shtml'>Tell me more about the CBeebies iPlayer</a></p></div>");var D='<div class="customTemplate"><div class="customTemplate-head"><div class="panel-hd"></div></div><div class="customTemplate-body"><div class="panel-bd"></div></div><div class="panel-ft"></div><div class="customTemplate-bottom"><a href="#" class="panel-close">Close<span><!-- --></span></a></div></div>';this.iPlayerPanel=new glow.widgets.Panel(B,{modal:true,className:"cbb-iplayer-msg",width:514,template:D,hideWhileShown:glow.dom.get(".cbb-sound-toggle-btn")});this.iPlayerPanel.content.addClass("cbb-iplayer-lb");glow.events.addListener(E,"click",function(F){if(cbb.site.interstitial.showThis){cbb.site.interstitial.iPlayerPanel.show()}else{cbb.site.interstitial.launchIPlayer()}F.preventDefault()});glow.events.addListener(glow.dom.get("#iplayer_no"),"click",function(F){cbb.site.interstitial.iPlayerPanel.hide();F.preventDefault()});glow.events.addListener(glow.dom.get("#iplayer_yes"),"click",function(F){cbb.site.interstitial.launchIPlayer();F.preventDefault()});glow.events.addListener(glow.dom.get("input#show-again"),"click",function(G){cbb.site.interstitial.showThis=!G.source.checked;var F=(cbb.site.interstitial.showThis)?"true":"false";cbb.site.writeCookie("cbb-iplayer-msg",F)})},launchIPlayer:function(){window.location="/iplayer/cbeebies/"}};cbb.site.toggleSound={isOn:true,init:function(){this.checkCookie();this.addSoundToggle();this.addListeners()},addSoundToggle:function(){var A="cbb-sound-toggle-btn";if(this.isOn){A+=" cbb-sound-on"}var B=glow.dom.create('<li class="'+A+'"><a href="#"><span> </span></a></li>');glow.dom.get("ul#cbb-nav-globals").append(B)},addListeners:function(){glow.events.addListener(".cbb-sound-toggle-btn","click",this.clickEventHandler,this)},clickEventHandler:function(A){this.toggleSound();this.updateBtn();A.preventDefault()},checkCookie:function(){var A=cbb.site.readCookie("cbb-nav-sound-enabled");if(A=="false"){this.isOn=false}else{this.isOn=true}},setCookie:function(){var A=(!this.isOn)?"false":"true";cbb.site.writeCookie("cbb-nav-sound-enabled",A)},updateBtn:function(){var A=glow.dom.get(".cbb-sound-toggle-btn");A.toggleClass("cbb-sound-on")},updateFlash:function(){window.document.getElementById("cbb-banner-swf").toggleSound(this.isOn);window.document.getElementById("cbb-shows-swf").toggleSound(this.isOn)},toggleSound:function(){this.isOn=!this.isOn;this.updateFlash();this.setCookie()},getSound:function(){return this.isOn}};cbb.site.guInfo={isAnimated:true,wrapperHeights:[],preventInteraction:true,rollColours:{games:"#9a0611",songs:"#da3505",makes:"#0b7889",stories:"#037e03",watch:"#b00a65"},init:function(){this.wrapInformation(glow.dom.get("div.cbb-grownups"));this.addPointer(glow.dom.get("div.cbb-grownups h3"));this.hideContainers(glow.dom.get(".cbb-grownups-wrapper"));this.addListeners("div.cbb-grownups h3")},wrapInformation:function(A){A.each(function(C){var D=cbb.site.guInfo.wrapperHeights.length;this==A[C];var B=glow.dom.get(this).get(".cbb-grownups-wrapper");B.attr("id","gu-wrapper-id-"+D);B.css("overflow","hidden");cbb.site.guInfo.wrapperHeights.push({id:D,height:B.css("height")})})},addPointer:function(A){A.addClass("cbb-grownups-btn")},hideContainers:function(A){A.each(function(B){this==A[B];if(cbb.site.guInfo.isAnimated){var E=glow.anim.css(this,0.25,{height:{to:0}}).start();cbb.site.guInfo.preventInteraction=true;var C=glow.dom.get(this);var D=glow.events.addListener(E,"complete",function(){C.hide();glow.events.removeListener(this);cbb.site.guInfo.preventInteraction=false})}else{glow.dom.get(this).hide()}})},showContainers:function(A){A.each(function(D){this==A[D];var B,C=0;var H=parseInt(glow.dom.get(this).attr("id").replace("gu-wrapper-id-",""));for(;C<cbb.site.guInfo.wrapperHeights.length;++C){if(cbb.site.guInfo.wrapperHeights[C].id==H){B=cbb.site.guInfo.wrapperHeights[C].height}}if(cbb.site.guInfo.isAnimated){glow.dom.get(this).show();var G=glow.anim.css(this,0.5,{height:{to:B}}).start();cbb.site.guInfo.preventInteraction=true;var E=glow.dom.get(this);var F=glow.events.addListener(G,"complete",function(){glow.events.removeListener(this);cbb.site.guInfo.preventInteraction=false;glow.dom.get(".cbb-promo").css("height","auto")})}else{glow.dom.get(this).show()}})},clickEventHandler:function(B){if(cbb.site.guInfo.preventInteraction){return }var A=glow.dom.get(B.attachedTo);A.toggleClass("cbb-grownups-info-on");var C=A.parent().get(".cbb-grownups-wrapper");if(C.css("height")=="0px"){this.showContainers(C)}else{this.hideContainers(C)}B.preventDefault()},addListeners:function(A,D){glow.events.addListener(A,"click",this.clickEventHandler,this);var C=glow.dom.get(A);if(!D&&glow.dom.get("body").hasAttr("class")){var B=glow.dom.get("body").attr("class").split(" ");D=B[0].substring(4);glow.events.addListener(glow.dom.get(A),"mouseover",function(E){glow.dom.get(this).toggleClass("btn-mouse-over")});glow.events.addListener(glow.dom.get(A),"mouseout",function(){glow.dom.get(this).toggleClass("btn-mouse-over")});glow.events.addListener(glow.dom.get(".cbb-promo.cbb-"+D+" .cbb-grownups-btn"),"mouseover",function(){glow.dom.get(".cbb-"+D+" .cbb-grownups-btn").css("color",cbb.site.guInfo.rollColours[D])});glow.events.addListener(glow.dom.get(".cbb-promo.cbb-"+D+" .cbb-grownups-btn"),"mouseout",function(){glow.dom.get(".cbb-"+D+" .cbb-grownups-btn").css("color","#000")})}}}})();gloader.load(["glow","1","glow.dom","glow.anim","glow.events","glow.embed","glow.widgets.Panel"],{async:false,onLoad:function(A){glow=A;glow.ready(function(){cbb.site.init()})}});function fullScreenPop(B){var A=600,C=400;if(window.screen){A=window.screen.availWidth-12;C=window.screen.availHeight-48}pop_window=window.open(B,"fullwin","width="+A+",height="+C+",left=0,screenX=0,top=0,screenY=0,fullscreen=no,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes");self.name="main"}function openNewWindow(A){fullScreenPop(A)};