if(window.cbb==undefined){cbb={}}(function(){cbb.carousel={cbbCarousel:null,isNext:false,timer:null,hasLooped:false,count:0,total:0,init:function(){if(glow.dom.get("#cbb-carousel").length==0){return }this.total=glow.dom.get("#cbb-carousel li").length;this.createCarousel();this.setCTAs();this.addEventListeners();this.startLoop()},createCarousel:function(){cbb.carousel.cbbCarousel=new glow.widgets.Carousel("#cbb-carousel",{loop:true,size:2});glow.dom.get("#cbb-slideshow ul li").css("position","relative");var B=glow.dom.get(".carousel-prev");var A=glow.dom.get(".carousel-next");B.addClass("cbb-back");A.addClass("cbb-next");glow.dom.get(this.cbbCarousel.visibleItems()[0]).addClass("cbb-activeslide")},addEventListeners:function(){glow.events.addListener(glow.dom.get(".carousel-prev"),"click",function(A){A.preventDefault();cbb.carousel.toPrevious()});glow.events.addListener(glow.dom.get(".carousel-next"),"click",function(A){A.preventDefault();cbb.carousel.toNext()});glow.events.addListener(glow.dom.get("#cbb-slideshow"),"mouseenter",function(A){A.preventDefault();cbb.carousel.stopLoop()});glow.events.addListener(glow.dom.get("#cbb-slideshow"),"mouseleave",function(A){A.preventDefault();cbb.carousel.startLoop()})},setCTAs:function(){this.cbbCarousel.items.each(function(D){this==cbb.carousel.cbbCarousel.items[D];var G=glow.dom.get(this);var F="";var A=G.get("a").attr("title");var C=G.get("a").attr("href");var B;if(C!=undefined){if(C.match(/songs/)){B="songs";F="<a href='"+C+"'>Sing<span><!-- --></span></a>"}else{if(C.match(/games/)){B="games";var E=(G.get("a").hasClass("lightbox"))?"class='carousel-lightbox'":"";F="<a href='"+C+"' "+E+">Play<span><!-- --></span></a>"}else{if(C.match(/stories/)){B="stories";F="<a href='"+C+"'>Read<span><!-- --></span></a>"}else{if(C.match(/makes/)){B="makes";F="<a href='"+C+"'>Make<span><!-- --></span></a>"}else{if(C.match(/watch/)){B="watch";F="<a href='"+C+"'>Watch<span><!-- --></span></a>"}}}}}}if(A==undefined|B==undefined){return }var H="<p>"+A+F+"</p>";if(G.get(".cbb-slide-info").length>0){G.get(".cbb-slide-info").remove()}G.append('<div class="'+B+' cbb-slide-info"><span class="opacity"><!-- --></span>'+H+"</div>")});glow.events.addListener(glow.dom.get(".carousel-lightbox"),"click",function(A){if(cbb.lb){cbb.lb.launchLB(A.attachedTo.href)}A.preventDefault()});if(cbb.lb.panel){glow.events.addListener(cbb.lb.panel,"afterHide",function(A){cbb.carousel.startLoop()});glow.events.addListener(cbb.lb.panel,"afterShow",function(A){cbb.carousel.stopLoop()})}},startLoop:function(){if(!this.hasLooped){cbb.carousel.timer=setInterval(function(){cbb.carousel.toNext()},3000)}},stopLoop:function(){clearInterval(cbb.carousel.timer)},toPrevious:function(){this.isNext=false;this.cbbCarousel.prev();this.updateActiveSlide()},toNext:function(){this.count++;this.isNext=true;this.cbbCarousel.next();this.updateActiveSlide();if(this.count>=this.total){this.hasLooped=true;this.stopLoop()}},updateActiveSlide:function(){glow.dom.get(".cbb-activeslide").removeClass("cbb-activeslide");if(this.isNext){glow.dom.get(this.cbbCarousel.visibleItems()[0]).next().addClass("cbb-activeslide")}else{glow.dom.get(this.cbbCarousel.visibleItems()[0]).addClass("cbb-activeslide")}}}})();gloader.load(["glow","1","glow.anim","glow.widgets.Carousel"],{async:true,onLoad:function(A){A.ready(function(){cbb.carousel.init()})}});