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 e=n,i=n.Pagination,r,u,o,s,f;i.property.number.page=t;$(i.selector.wrapper).length==1&&(r=window.location,u=[r.origin,r.pathname,r.search,"#page",t].join(""),history&&history.pushState?(o=typeof n.property.parent.Filter!="undefined"?n.property.parent.Filter.property.parametersForAjax:null,history.pushState(o,"Page",u)):window.location=u);e.Output.init();i.property.callbacks.onpage!==undefined&&i.property.callbacks.onpage();s=$(".h-wrapper").find("[data-js-fixed-wrapper]").first().outerHeight();f=e.elements.resultsTop.offset().top-s;$("body, html").animate({scrollTop:f>0?f:0},500)}}}(),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();t.element.list=$(".e-pagination__list",t.element.wrapper);(typeof t.element.list=="undefined"||t.element.list.length==0)&&(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(n){var u=$(n.target),i,r;u.closest(t.selector.item).length&&t.element.wrappingEl.find($(n.target)).length&&(i=u.closest("a"),r=i.data("page"),i.length&&typeof r!="undefined"&&(t.methods.goToPage(r),n.preventDefault(),n.stopPropagation()))})}}}())}