function FilterBox(n,t,i,r){var u=this,o;this.language=$("input.W2DAskTagLanguage").val();this.selectedFilters=[];this.availableTags=n;this.endpointname=t;this.endpoint={momsPanel:"/moms.aspx/FilterPanel",favorites:"/moms-panel-favorites.aspx/FilterFavorites",momsViews:"/mom-views.aspx/FilterMomViews",video:"/moms-panel-videos.aspx/FilterVideo",extras:"/panelextras-list.aspx/FilterPanelExtras"}[t];let f,e;this.readerCopy={addTokenCopy:"",removeTokenCopy:""};f=document.querySelector("input.W2DAddTagMessage");e=document.querySelector("input.W2DRemoveTagMessage");f&&(this.readerCopy.addTokenCopy='<span class="hidden">'+f.value+"<\/span>");e&&(this.readerCopy.removeTokenCopy='<span class="hidden">'+e.value+"<\/span>");this.initialFilters=t==="momsPanel"?n.filter(function(n){return n.Language===u.language}):t==="favorites"||t==="video"||currentPage==="extras"?r.filter(function(n){return n.Language===u.language}):n.filter(function(n){return n.TagLevel===0&&n.Language===u.language});this.elements=i||{availableTags:$("#availableTags"),selectedTags:$("#selectedTokens"),buttonContainer:$("#showMoreContainer"),moreTagsButton:$("div.viewMore"),moreButtonID:"more-tags-btn",lessButtonID:"less-tags-btn",moreButtonHTML:'<div class="viewMore" id="more-tags-btn"><i class="icon" aria-hidden="true">&#58117;<\/i><a href="#" tabindex="0" aria-expanded="false">'+$("input[id$=hidShowMore]").val()+"<\/a><\/div>",lessButtonHTML:'<div class="viewMore" id="less-tags-btn" style="display:none;"><i class="icon" aria-hidden="true" >&#58118;<\/i><a href="#" aria-expanded="true">'+$("input[id$=hidShowLess]").val()+"<\/a><\/div>"};this.moreTagsButtonAdded=!1;o=this.initialFilters.map(function(n){return n.TagName});uniq(o).forEach(function(n){u.elements.availableTags.append(u.createFilterNode(n))});this.showMoreLess()}function addQCountCommas(n){return(n+"").replace(/(\d)(?=(\d{3})+$)/g,"$1,")}function closeTopList(){$listDetailTemplate.fadeOut("slow",function(){var u=$(this),f=u.closest("ul"),r,t;if(listCurrentIndex>=0){var e=document.getElementById("hidReadLess").value,i=document.getElementById("hidReadMore").value,n=f.children().eq(listCurrentIndex).find("a.topTenReadMore");n.html(i);n.attr("aria-label",n.attr("aria-label").replace(e,i));n.focus()}$("#olList").removeClass();$("#olList").html("");$("#divTopListContent").removeClass();$listDetailTemplate.removeClass("topTenFullText left");$listDetailTemplate.detach();listCurrentIndex=-1;listID="";r=getTagIds(filterBox.selectedFilters);t={en:"/extras/",pt:"/pt/extras/",fr:"/fr/extras/",es:"/es/extras/"};r!==""?history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,t[filterBox.language]+"?tokens="+getTagIds(filterBox.selectedFilters)):history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,t[filterBox.language])})}function viewMoreExtras_Home(n){var r=$(n),u=r.closest("section"),t=u.data("token"),i;t&&(i={en:"/extras/",pt:"/pt/extras/",fr:"/fr/extras/",es:"/es/extras/"},location.href=i[filterBox.language]+"?tokens="+t)}function createThumb(){var n=Array.prototype.slice.call(document.querySelectorAll("#olList img[data-pdf-thumbnail-file]"));n.length>0&&(pdfjsLib||console.log("pdf.js failed to load. Check data-pdfjs-src attribute."),n.forEach(function(n){null===worker&&(worker=new pdfjsLib.PDFWorker);var t=n.getAttribute("data-pdf-thumbnail-file"),i=n.getAttribute("data-pdf-thumbnail-width"),r=n.getAttribute("data-pdf-thumbnail-height");pdfjsLib.getDocument({url:t,worker:worker}).promise.then(function(u){u.getPage(1).then(function(t){var f=document.createElement("canvas"),u=t.getViewport({scale:1}),e=f.getContext("2d");i?u=t.getViewport({scale:i/u.width}):r&&(u=t.getViewport({scale:r/u.height}));f.height=u.height;f.width=u.width;t.render({canvasContext:e,viewport:u}).promise.then(function(){n.src=f.toDataURL()})}).catch(function(){console.log("pdfThumbnails error: could not open page 1 of document "+t+". Not a pdf ?")})}).catch(function(){console.log("pdfThumbnails error: could not find or open document "+t+". Not a pdf ?")})}))}var currentPage,filterTimer,filterBox,qs,re,$listDetailTemplate,listCurrentIndex,listID,worker,slistTemplate;FilterBox.prototype.createFilterNode=function(n,t){switch(t){case"selected":return'<li class="tokenWrapper"><div class="tokenContainer" role="button" tabindex="0"><span class="tokenText">'+n+'<\/span><span class="tokenRemove icon" aria-hidden="true">&#58112;<\/span>'+this.readerCopy.removeTokenCopy+"<\/div><\/li>";default:return'<li class="tokenWrapper"><div class="tokenContainer" role="button" tabindex="0"><span class="tokenText">'+n+'<\/span><span class="tokenAdd" aria-hidden="true">&#43;<\/span>'+this.readerCopy.addTokenCopy+"<\/div><\/li>"}};FilterBox.prototype.addFilter=function(n){var t=this;this.selectedFilters.push(n);this.elements.selectedTags.empty();uniq(this.selectedFilters).forEach(function(n){t.elements.selectedTags.append(t.createFilterNode(n,"selected"))});$("#divTagInstructions").css("display","none")};FilterBox.prototype.removeFilter=function(n){this.selectedFilters=uniq(this.selectedFilters);var i=this.selectedFilters.indexOf(n),t=this;this.selectedFilters.splice(i,1);this.elements.selectedTags.empty();uniq(this.selectedFilters).forEach(function(n){t.elements.selectedTags.append(t.createFilterNode(n,"selected"))});this.selectedFilters.length>0?$("#divTagInstructions").css("display","none"):$("#divTagInstructions").css("display","block")};FilterBox.prototype.search=function(){var n=this;search({tokens:getTagIds(this.selectedFilters)},function(t){var i=JSON.parse(t.d),r;n.endpointname=="video"?($("div.videoCatList").empty(),$("div.videoCatList").append(i.FormattedHtml)):n.endpointname=="momsViews"?(page=1,$("li[id$='liViewMoreViews']").prevAll().remove(),$("li[id$='liViewMoreViews']").before(i.FormattedHtml),$("h1[id$=oH1]").text(addQCountCommas(i.QuestionCount)+" "+i.RecentFoundText),setMomsReadMore(),$(".hasTooltip").each(function(n,t){$(this).qtip({style:{classes:"popPanelist"},content:{text:$(this).next("div")},show:{event:"keyup mouseover",effect:function(){var i=0,n=0,u=$(t).closest("li").outerHeight(!0),f=$(t).closest("li").outerWidth(!0),r;$(t).closest("li").prevAll().each(function(t,r){$(r).hasClass("title")==!1&&(i=$(r).outerHeight(!0)+i,n=$(r).outerWidth(!0)+n)});i=$(t).closest("li").outerHeight(!0)+i;n=$(t).closest("li").outerWidth(!0)+n;n>0&&n+20>=$(t).closest("ul").outerWidth(!0)&&$(t).closest("ul").next("a.readMore")[0]!==undefined&&(r=$(t).closest("ul").next("a.readMore"),r.attr("name")!==undefined&&r.attr("name")=="amMore"&&r.click());$(this).fadeTo(500,1)}},hide:{event:"unfocus keydown mouseout",fixed:!0,delay:300},position:{my:"bottom center",at:"top center"}})}),$("input[id$='hidEndPage']").val(i.EndPage),1>=i.EndPage?$("li[id$='liViewMoreViews']").hide():$("li[id$='liViewMoreViews']").show()):n.endpointname=="extras"?(page=1,$listDetailTemplate.find("#olList").removeClass(),$listDetailTemplate.find("#olList").html(""),$listDetailTemplate.find("#divTopListContent").removeClass(),$listDetailTemplate.removeClass("topTenFullText left"),$listDetailTemplate.detach(),listCurrentIndex=-1,listID="",$("#divTopTen").empty(),$("#divTopTen").append(i.FormattedHtml)):(page=1,$("ul.questionList").empty(),$("ul.questionList").append('<li class="fadeWrap"><hr class="fade" /><\/li>'+i.FormattedHtml),n.endpointname=="favorites"?($("ul.listInfo .listTotal").text(addQCountCommas(i.QuestionCount)+" "+i.RecentFoundText),$("input[id$='hidEndPage']").val(i.EndPage),1>=i.EndPage?$("div[id$='divViewMoreLink']").hide():$("div[id$='divViewMoreLink']").show()):$("ul.listInfo .listTotal").text(addQCountCommas(i.PanelCount)+" "+i.PanelFoundText));r=[];i.TagIDs.forEach(function(t){n.availableTags.forEach(function(i){i.TagID===t.TagID&&n.language===i.Language&&r.push(i.TagName)})});n.elements.availableTags.empty();uniq(r).forEach(function(t){n.elements.availableTags.append(n.createFilterNode(t))});n.showMoreLess()},this.endpoint)};FilterBox.prototype.init=function(n){var t=this,i=[];n.forEach(function(n){t.availableTags.forEach(function(r){r.TagID===parseInt(n)&&r.Language===t.language&&i.push(r.TagName)})});this.selectedFilters=uniq(i);$("#divTagInstructions").css("display","none");this.selectedFilters.forEach(function(n){t.elements.selectedTags.append(t.createFilterNode(n,"selected"))})};FilterBox.prototype.showMoreLess=function(){if(this.elements.availableTags[0]!==undefined){var t=this.elements.availableTags[0].scrollHeight,n=95;(this.endpointname==="video"||this.endpointname==="momsViews")&&(n=84);t>n?(this.moreTagsButtonAdded||(this.elements.buttonContainer.prepend(this.elements.moreButtonHTML),this.elements.buttonContainer.append(this.elements.lessButtonHTML),this.moreTagsButtonAdded=!0),this.elements.buttonContainer.css({display:"block"}),$("#"+this.elements.moreButtonID).css({display:"block"}),$("#"+this.elements.lessButtonID).css({display:"none"})):this.elements.buttonContainer.css({display:"none"});this.elements.availableTags.attr("style")!==undefined&&this.elements.availableTags.attr("style","")}};filterTimer=null;window.location.pathname.indexOf("meet-the-panel")>-1?currentPage="momsPanel":window.location.pathname.indexOf("panelist-views")>-1?currentPage="momsViews":window.location.pathname.indexOf("saved-answers")>-1?currentPage="favorites":window.location.pathname.indexOf("plandisney-video-library")>-1?currentPage="video":window.location.pathname.indexOf("extras")>-1&&(currentPage="extras");filterBox=currentPage==="favorites"?new FilterBox(tagMap,currentPage,!1,favoritesMap):currentPage==="video"?new FilterBox(tagMap,currentPage,!1,vidsMap):currentPage==="extras"?new FilterBox(tagMap,currentPage,!1,pExtrasMap):new FilterBox(tagMap,currentPage);$("#availableTags").on("click keypress",".tokenWrapper",function(n){var t,r,i,u,f;if(n.type!="keypress"||n.keyCode==13){n.preventDefault();t=$(".tokenText",this).text();filterBox.addFilter(t);r=t;try{currentPage==="extras"&&(i=getTagIds_Array([t]),i&&i.length>0&&$.ajax({type:"POST",url:"/panelextras-list.aspx/TrackExtraTokens",data:JSON.stringify({TokenID:i[0]}),contentType:"application/json; charset=utf-8"}).fail(function(n,t,i){console.log(i);console.log(n.responseText)}))}catch(n){}try{u=r.replace(/\s+/g,"");WDPRO.Analytics.Framework.trackElement("moreSearchResults",{trackingType:"customLink",linkId:u+"_apply",facetsUtilized:[{name:r,action:"add"}]})}catch(n){}filterBox.search();currentPage==="extras"?(f={en:"/extras/",pt:"/pt/extras/",fr:"/fr/extras/",es:"/es/extras/"},history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,f[filterBox.language]+"?tokens="+getTagIds(filterBox.selectedFilters))):history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,window.location.pathname+"?tokens="+getTagIds(filterBox.selectedFilters))}});$("#divFilterContainer").on("scroll",function(){filterTimer!==null&&clearTimeout(filterTimer);filterTimer=setTimeout(function(){var n=$("#availableTags"),t=$("#more-tags-btn"),r,i;n.css({height:"auto"});r=document.activeElement;i=t.children("a").first().is(":focus");i&&n.children().last().children().eq(0).focus();t.hide();$("#less-tags-btn").show()},750)});$("#availableTags").on("keyup",".tokenContainer",function(n){n.keyCode===9&&($("#availableTags").css({height:"auto"}),$("#more-tags-btn").hide(),$("#less-tags-btn").show())});$("#selectedTokens").on("click keypress",".tokenWrapper",function(n){var t,i,r;if(n.type!="keypress"||n.keyCode==13){n.preventDefault();filterBox.removeFilter($(".tokenText",this).text());t=$(".tokenText",this).text();try{i=t.replace(/\s+/g,"");WDPRO.Analytics.Framework.trackElement("moreSearchResults",{trackingType:"customLink",linkId:i+"_remove",facetsUtilized:[{name:t,action:"remove"}]})}catch(n){}filterBox.search();currentPage==="extras"?(r={en:"/extras/",pt:"/pt/extras/",fr:"/fr/extras/",es:"/es/extras/"},history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,r[filterBox.language]+"?tokens="+getTagIds(filterBox.selectedFilters))):history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,window.location.pathname+"?tokens="+getTagIds(filterBox.selectedFilters))}});$("#showMoreContainer").on("click","#more-tags-btn",function(n){n.preventDefault();$("#availableTags").css({height:"auto"});$(this).hide();$("#less-tags-btn").show().children("a").first().focus()});$("#showMoreContainer").on("click","#less-tags-btn",function(n){n.preventDefault();$("#availableTags").attr("style","")!==undefined&&$("#availableTags").attr("style","");$(this).hide();$("#more-tags-btn").show().children("a").first().focus()});if(qs=queryString(),qs&&qs.tokens&&(re=/^\d+(?:,\d+)*$/g,re.test(qs.tokens)&&filterBox.init(qs.tokens.split(","))),listCurrentIndex=-1,listID="",currentPage==="extras"){worker=null;pdfjsLib?pdfjsLib.GlobalWorkerOptions.workerSrc="/scripts/pdfjs/pdf.worker.js":console.log("pdf.js not loaded yet.");$("#divTopTen").on("click keypress",".topTenList .topTenReadMore",function(n){var h,c,e,l,o,p;if(n.type!="keypress"||n.keyCode==13){n.preventDefault();var i=$(this),t=i.closest("li").index(),a=i.data("id"),f=document.getElementById("hidReadLess").value,r=document.getElementById("hidReadMore").value;if(a!==listID)this.innerHTML=document.getElementById("hidReadLess").value,e=this.getAttribute("aria-label"),this.setAttribute("aria-label",e.replace(r,f)),$listDetailTemplate.fadeOut("slow",function(){var o=$listDetailTemplate.closest("ul"),u;o&&listCurrentIndex>=0&&(u=o.children().eq(listCurrentIndex).find("a.topTenReadMore"),u.html(r),u.attr("aria-label",u.attr("aria-label").replace(f,r)));$listDetailTemplate.find("#olList").removeClass();$listDetailTemplate.find("#olList").html("");$listDetailTemplate.find("#divTopListContent").removeClass();$listDetailTemplate.removeClass("topTenFullText left");$listDetailTemplate.detach();listID=a;t=i.closest("li").index();listCurrentIndex=t;var n=i.closest("ul"),s=n.children().length,l=n.innerWidth(),v=n.children().eq(0).innerWidth(),e=Math.round(l/v),h=Math.floor(t/e),y=Math.ceil(s/e)-1,c=!1;typeof sChosenSlug!="undefined"&&sChosenSlug!==""&&sChosenSlug==i.data("id")&&(sChosenSlug="",c=!0);$.ajax({type:"POST",url:"/panelextras-list.aspx/getListDetails",data:JSON.stringify({Slug:i.data("id"),SaveV:!0}),contentType:"application/json; charset=utf-8",dataType:"json"}).done(function(i){var o,r,u,f;i!==""&&i.d!=""&&(i=$.parseJSON(i.d),y==h&&t==s-1?n.children().eq(t).after($listDetailTemplate):(o=e*(h+1)-1,n.children().eq(o).after($listDetailTemplate)),$("#h4ListTitle").html(i.ListName),r=$("#olList"),r.append(i.ItemList),i.ListType==0?r.addClass("applyForm questionList"):($listDetailTemplate.addClass("topTenFullText"),$("#divTopListContent").addClass("topTenTextSide")),i.ShowListMarker&&r.addClass("showListMarker"),e>1&&t%2==0&&$listDetailTemplate.addClass("left"),$listDetailTemplate.fadeIn("slow").css("display","block"),$listDetailTemplate.attr("data-id",i.Slug),c?($("html, body").animate({scrollTop:$("#divTopTen").find(".topTenFullStory").offset().top},100),createThumb()):(createThumb(),u=getTagIds(filterBox.selectedFilters),f={en:"/extras/",pt:"/pt/extras/",fr:"/fr/extras/",es:"/es/extras/"},u!==""?history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,f[filterBox.language]+i.Slug+"?tokens="+u):history.pushState({tokens:getTagIds(filterBox.selectedFilters)},null,f[filterBox.language]+i.Slug)))}).fail(function(n,t,i){console.log(i);console.log(n.responseText)})});else if(h=i.closest("section").data("token"),c=$listDetailTemplate.closest("section").data("token"),h&&c&&h!==c){this.innerHTML=document.getElementById("hidReadLess").value;e=this.getAttribute("aria-label");this.setAttribute("aria-label",e.replace(r,f));l=$listDetailTemplate.closest("ul");l&&listCurrentIndex>=0&&(o=l.children().eq(listCurrentIndex).find("a.topTenReadMore"),o.html(r),o.attr("aria-label",o.attr("aria-label").replace(f,r)));t=i.closest("li").index();listCurrentIndex=t;$listDetailTemplate.removeClass("left");$listDetailTemplate.detach();var u=i.closest("ul"),v=u.children().length,w=u.innerWidth(),b=u.children().eq(0).innerWidth(),s=Math.round(w/b),y=Math.floor(t/s),k=Math.ceil(v/s)-1;k==y&&t==v-1?u.children().eq(t).after($listDetailTemplate):(p=s*(y+1)-1,u.children().eq(p).after($listDetailTemplate));s>1&&t%2==0&&$listDetailTemplate.addClass("left");$listDetailTemplate.fadeIn("slow").css("display","block")}else closeTopList()}});slistTemplate='<li class="topTenFullStory" id="liListDetail" style="display: none;">';slistTemplate+='<a href="javascript:void(0);"  onclick="closeTopList();" class="buttonClose icon" aria-label="Close Extra">&#58112;<\/a>';slistTemplate+='<div id="divTopListContent">';slistTemplate+='<h4 id="h4ListTitle"><\/h4>';slistTemplate+='<p id="pListBody"><\/p>';slistTemplate+='<ol id="olList"><\/ol>';slistTemplate+="<\/div>";slistTemplate+='<a href="javascript:void(0);"  onclick="closeTopList();" class="buttonClose icon" aria-label="Close Extra">&#58112;<\/a>';slistTemplate+="<\/li>";$listDetailTemplate=$(slistTemplate);$listDetailTemplate.find("#olList").on("click keypress",".templateVideo .readMore, .templateVideo a.templateVideoLink",function(n){if(n.type!="keypress"||n.keyCode==13){n.preventDefault();var i=$(this),t=i.closest("div.templateVideo"),r=$("#liListDetail");playExtrasVideo(t.find("a.readMore").data("url"),r.attr("data-id"),t.find("a.readMore").data("vid"),i,t.find("a.readMore").data("vimg"))}});typeof sChosenSlug!="undefined"&&sChosenSlug!==""&&$("#divTopTen").find('[data-id="'+sChosenSlug+'"]').first().click()}