gloader.load(["glow","1","glow.dom","glow.events","glow.anim","glow.widgets.Carousel"],{async:true,onLoad:function(E){var D=E.dom,C=E.dom.get,A=E.events,B=E.anim;if(!E.isSupported){document.documentElement.className=""}Paginatedclips={nodeList:null,newNodeList:null,count:null,pageSize:null,pageToDisplay:null,carousel:null,init:function(F){this.nodeList=E.dom.get("#carousel .clip-promo");this.count=this.nodeList.length;if(!this.count){return }this.pageSize=F;this.pageCount=Math.ceil(this.count/this.pageSize);this.createHtml();E.dom.get("#carousel").css("display","block");this.loadCarousel()},createHtml:function(){if(E.dom.get("#carousel div").length){E.dom.get("#carousel div").remove()}var H="";for(var G=0;G<this.pageCount;G++){var F=parseInt(G+1);H+='<div class="page page-'+F+'"></div>'}this.newNodeList=E.dom.create(H);this.nodeList.each(function(J){var K=Math.floor(J/Paginatedclips.pageSize),I=K+1;Paginatedclips.newNodeList.slice(K,I).append(this)});E.dom.get("#carousel").append(this.newNodeList)},loadCarousel:function(){if(!this.count){return }Paginatedclips.carousel=new E.widgets.Carousel("#carousel",{loop:true,size:1,step:1,pageNav:true});E.anim.fadeIn("#carousel",0.6);var F=E.dom.get("#carousel .carousel-item").length-E.dom.get("#carousel .carousel-added").length;var G=E.dom.get("#clips ul.pageNav");if(F<2){G.remove()}else{E.dom.create('<div class="pageNavTop"></div>').insertBefore("#clips ul.pageNav");G.css("margin-left",this.getPageNavMargin()+"px");G.get("#rightarrow").before(E.dom.create('<li class="dot dotTotal">of <span class="number">'+F+"</span></li>"))}E.dom.get("#clips .carousel-window").css("height","auto");this.displayCorrectPage()},displayCorrectPage:function(){var F=this.getPageToDisplay();if(F>1){Paginatedclips.carousel.moveTo(F-1)}},getPageToDisplay:function(){this.pageToDisplay=Math.ceil(videoclips.matchedPromo/Paginatedclips.pageSize);return this.pageToDisplay},getPageNavMargin:function(){var I=E.dom.get(".carousel-window").width();var H=null;var G=E.dom.get("#clips .pageNav li");G.each(function(J){H+=G.slice(J,J+1).width()});var F=(I/2)-(H/2);if(F<0){return 0}else{return Math.floor(F)}},addNewCarousel:function(F){this.pageSize=F;this.pageCount=Math.ceil(this.count/this.pageSize);E.dom.get("#clips .carousel-window").parent().parent().remove();E.dom.create('<div class="clips-container" id="carousel"></div>').insertAfter("#videoempWrapper");this.createHtml();E.dom.get("#carousel").css("display","block");this.loadCarousel()}};videoclips={links:null,count:null,matchedPid:null,matchedPromo:1,init:function(){videoclips.links=E.dom.get("#clips h3 a");videoclips.count=videoclips.links.length;if(!videoclips.count){return }var H=E.dom.get("#videoempWrapper div").clone();E.dom.get("#videoempWrapper div").remove();var G;if(E.env.ie==6){E.dom.get("#videoempWrapper").append('<div id="resizeEmp"></div><div id="videoemp"></div>')}else{E.dom.get("#videoempWrapper").append('<div id="resizeEmp"><a href="#">Enlarge</a></div><div id="videoemp"></div>');E.dom.get("#resizeEmp a")[0].onclick=function(){videoclips.resizeEmp();return false}}videoclips.videoemp=E.dom.get("#videoemp");if(location.hash){var F=location.hash;F=F.slice(1,F.length);videoclips.checkPid(F)}if(this.matchedPid&&this.matchedPromo){videoclips.loadEmp(videoclips.matchedPid);videoclips.highlightSelected(videoclips.matchedPromo)}else{videoclips.loadEmp(videoclips.links[0].className);videoclips.highlightSelected(1)}if(!this.checkFlash("videoemp")){E.dom.get("#clips .box").addClass("lowFlash");E.dom.get("#videoempWrapper div").remove();E.dom.get("#videoempWrapper").append(H)}else{videoclips.links.each(function(J){var I=J+1;E.events.addListener("#clips .nth-child-"+I+" h3 a","click",function(){videoclips.loadEmp(this.className,true);videoclips.highlightSelected(I);location.hash=this.className;return false})})}},checkPid:function(F){videoclips.links.each(function(G){if(F==this.className){videoclips.matchedPromo=G+1;videoclips.matchedPid=F}});return false},checkFlash:function(G){var F=embeddedMedia.playerInstances[G].so.attributes.version;this.installedFlashPlayer=deconcept.SWFObjectUtil.getPlayerVersion();if(F.major<=this.installedFlashPlayer.major&&F.minor<=this.installedFlashPlayer.minor&&F.rev<=this.installedFlashPlayer.rev&&document.documentElement&&document.getElementById){return true}},loadEmp:function(H,G){var F="http://www.bbc.co.uk/iplayer/playlist/"+H+"/suppress_masterbrand";videoEmp=new bbc.Emp();videoEmp.setWidth("100%");videoEmp.setHeight("100%");videoEmp.setDomId("videoemp");videoEmp.setPlaylist(F);videoEmp.set("config_settings_skin","black");videoEmp.setConfig("http://www.bbc.co.uk/emp/iplayer/offschedule.xml");if(G){videoEmp.set("config_settings_autoPlay","true")}videoEmp.write()},resizeEmp:function(){videoclips.videoemp=E.dom.get("#videoemp");if(videoclips.videoemp[0].clientWidth<257){new E.anim.Timeline([animations.hideContent,0.6,animations.enlargeVideo,1,animations.displaySmallCarousel]).start()}else{new E.anim.Timeline([animations.hideContent,0.6,animations.shrinkVideo,1,animations.displayLargeCarousel]).start()}},highlightSelected:function(F){var H=F-1,G=E.dom.get("#clips div.clips-container div.clip-promo");G.removeClass("selected");G.slice(H,F).addClass("selected");E.dom.get("#clips div.clips-container").addClass("withemp");videoclips.matchedPromo=F}};animations={hideContent:function(){E.anim.fadeOut(".pageNav",0.5);E.anim.fadeOut("#carousel",0.5);E.anim.fadeOut(".pageNavTop",0.5)},enlargeVideo:function(){E.anim.css("#videoemp",1,{width:{to:"640px"},height:{to:"395px"}}).start();E.anim.css("#videoempWrapper",1,{width:{to:"640px"},height:{to:"420px"}}).start()},displaySmallCarousel:function(){E.dom.get("#clips").addClass("bigEmp");E.dom.get("#resizeEmp a").text("Shrink");Paginatedclips.addNewCarousel(3)},shrinkVideo:function(){E.anim.css("#videoemp",1,{width:{to:"256px"},height:{to:"179px"}}).start();E.anim.css("#videoempWrapper",1,{width:{to:"256px"},height:{to:"204px"}}).start()},displayLargeCarousel:function(){E.dom.get("#clips").removeClass("bigEmp");E.dom.get("#resizeEmp a").text("Enlarge");Paginatedclips.addNewCarousel(4)}};herosounds={links:null,count:null,facetType:null,facetId:null,firstFilename:null,playlistUrl:null,width:306,init:function(){herosounds.links=E.dom.get("#sounds li a");herosounds.count=herosounds.links.length;if(!herosounds.count){return }var G=window.location.href;var H=G.split("/");herosounds.facetType=H[4];herosounds.facetId=E.dom.get("#sounds ol")[0].className;herosounds.firstFilename=herosounds.extractFilename(herosounds.links[0].pathname);var F=E.dom.get("#lead-row");if(F.hasClass("bbc-content-and-hero-sound")){herosounds.width=386}else{if(F.hasClass("only-hero-sound")){herosounds.width=466}}if(herosounds.firstFilename){E.dom.get("#sounds").append('<div id="emp"></div>');herosounds.loadEmp(herosounds.firstFilename)}if(!this.checkFlash("emp")){E.dom.get("#lead-row").addClass("lowFlash")}else{if(herosounds.count>1){herosounds.loadConsole()}}},extractFilename:function(F){var G=/\/([^\/]+)\.mp3/;if(F.match(G)){return RegExp.$1}},checkFlash:function(G){var F=embeddedMedia.playerInstances[G].so.attributes.version;this.installedFlashPlayer=deconcept.SWFObjectUtil.getPlayerVersion();if(F.major<=this.installedFlashPlayer.major&&F.minor<=this.installedFlashPlayer.minor&&F.rev<=this.installedFlashPlayer.rev&&document.documentElement&&document.getElementById){return true}},loadEmp:function(F){herosounds.playlistUrl="http://www.bbc.co.uk/earth/naturelibrary/playlists/"+herosounds.facetType+"/"+herosounds.facetId+"/"+F;var G=new bbc.Emp();G.setWidth(herosounds.width);G.setHeight("106");G.setDomId("emp");G.set("config_settings_displayMode","audio");G.setPlaylist(herosounds.playlistUrl);G.write()},loadConsole:function(){var G='<select id="sounds-select" onchange="herosounds.loadEmp(herosounds.extractFilename((herosounds.links[this.selectedIndex].href)))">';for(var F=0;F<herosounds.count;F++){G+="<option>"+herosounds.links[F].firstChild.data+"</option>"}G+="</select>";E.dom.get("#sounds").append(G)}};(function(){E.ready(function(){herosounds.init();videoclips.init();Paginatedclips.init(4)})})()}});