var Pagination=function(n){typeof n!="undefined"&&(this.selector={wrapper:"[data-js-pagination-wrapper]",item:"[data-js-pagination-item]"},this.element={wrapper:undefined,list:undefined,wrappingEl:undefined},this.property={markup:{prev:null,pages:[],next:null},number:{page:undefined,resultsPerPage:10,pages:undefined,results:undefined},callbacks:{onpage:undefined}},this.init=function(){this.setup.init()},this.methods=function(){return{goToPage:function(t){var r=n.Pagination,i;typeof t=="number"&&typeof r.element.list!="undefined"&&(i=$(r.element.list).find('[data-page="'+t+'"]').first(),i.length&&i.click())}}}(),this.setup=function(){return{init:function(){var i=n,t=n.Pagination;t.property.number.results>t.property.number.resultsPerPage?(this.element(),t.element.wrapper.length&&t.element.list.length&&(this.pages(),this.prev(),this.next(),this.html())):t.element.wrapper=$(t.selector.wrapper,t.element.wrappingEl).first().hide()},element:function(){var i=n,t=n.Pagination;t.element.wrapper=$(t.selector.wrapper,t.element.wrappingEl).first();typeof t.element.list=="undefined"&&(t.element.list=$("<ul class='e-pagination__list'><\/ul>"),t.element.wrapper.append(t.element.list));t.element.wrapper.length&&t.element.list.length?t.element.wrapper.show():t.element.wrapper.hide()},pages:function(){var t=n.Pagination,s=t.property.number.page,r=10,o=1,u=t.property.number.pages,f=t.property.number.pages,c=!1,h=!1,i,e;for(f>r&&(s>r/2?(c=!0,s<f-r/2?(h=!0,o=s-(Math.ceil(r/2)-1),u=s+Math.ceil(r/2)):(u=f,o=f-(r-1))):(h=!0,u=r)),c&&(e=["",'<li class="e-pagination__item" data-js-pagination-item>','<a href="#" class="e-pagination__link" data-page="'+(o-5<1?1:o-5)+'"><span aria-hidden="true">...<\/span><span class="sr-only">Previous Group<\/span><\/a>',"<\/li>",""].join(""),t.property.markup.pages.push(e)),i=o;i<=u;i++)e=["",'<li class="e-pagination__item'+(i===t.property.number.page?" is-current":"")+'" data-js-pagination-item>',i===t.property.number.page?'<span class="e-pagination__link">'+i.toString()+'<span class="sr-only"> - Current page<\/span><\/span>':'<a href="#" class="e-pagination__link" data-page="'+i.toString()+'">'+i.toString()+"<\/a>","<\/li>",""].join(""),t.property.markup.pages.push(e);h&&(e=["",'<li class="e-pagination__item" data-js-pagination-item>','<a href="#" class="e-pagination__link" data-page="'+(u+5>f?f:u+5)+'"><span aria-hidden="true">...<\/span><span class="sr-only">Next Group<\/span><\/a>',"<\/li>",""].join(""),t.property.markup.pages.push(e))},prev:function(){var t=n.Pagination;t.property.markup.prev=["",'<li class="e-pagination__item" data-js-pagination-item>',t.property.number.page<=1?'<span class="e-pagination__prev">':'<a href="#" rel="prev" data-page="'+(t.property.number.page-1).toString()+'" class="e-pagination__prev is-link">',Site.SVGMarkup("chevron-left"),'<span class="sr-only">Previous<\/span>',t.property.number.page<=1?"<\/span>":"<\/a>","<\/li>",""].join("")},next:function(){var t=n.Pagination;t.property.markup.next=["",'<li class="e-pagination__item" data-js-pagination-item>',t.property.number.page>=t.property.number.pages?'<span class="e-pagination__next">':'<a href="#" rel="next" data-page="'+(t.property.number.page+1).toString()+'" class="e-pagination__next is-link">',Site.SVGMarkup("chevron-right"),'<span class="sr-only">Next<\/span>',t.property.number.page>=t.property.number.pages?"<\/span>":"<\/a>","<\/li>",""].join("")},html:function(){var t=n.Pagination,i=t.property.markup,r=[i.prev,i.pages.join(""),i.next].join("");t.element.list.html(r);t.element.wrapper.show()}}}(),this.events=function(){return{init:function(){this.click()},click:function(){var i=n,t=n.Pagination;window.onpopstate=function(){i.Update()};$(document).on("click",function(r){var h=$(r.target),e,u,f,o,c,l,s;h.closest(t.selector.item).length&&t.element.wrappingEl.find($(r.target)).length&&(e=h.closest("a"),u=e.data("page"),e.length&&typeof u!="undefined"&&(t.property.number.page=u,$(t.selector.wrapper).length==1&&(f=window.location,o=[f.origin,f.pathname,f.search,"#page",u].join(""),history&&history.pushState?(c=typeof n.property.parent.Filter!="undefined"?n.property.parent.Filter.property.parametersForAjax:null,history.pushState(c,"Page",o)):window.location=o),i.Output.init(),t.property.callbacks.onpage!==undefined&&t.property.callbacks.onpage(),l=$(".h-wrapper").find("[data-js-fixed-wrapper]").first().outerHeight(),s=i.elements.resultsTop.offset().top-l,$("body, html").animate({scrollTop:s>0?s:0},500),r.preventDefault(),r.stopPropagation()))})}}}())}