function getArticles(n){var o=$("#js_news_listing"),r=$("#js_news_listing_results"),i=$("#js_results_text"),y=$("#js_search_field").val(),u=$("#js_results_order"),t=$("#js_items_per_page_list"),p=0,f=helper.getParameterByName("theme"),e=helper.getParameterByName("group"),s=[],c=$("body").data("current-language"),l=o.data("parent-id"),a=$("#js_from").val(),v=$("#js_to").val(),h;$("#js_themes option:selected").not("._js_fake").each(function(){f=$(this).val()});$("#js_categories option:selected").not("._js_fake").each(function(){p=parseInt($(this).val())});$("input.js_filter_tag:checked").each(function(){s.push(parseInt($(this).data("tag-id")))});helper.initAutocomplete("#js_search_field","/umbraco/surface/listing/getarticlesautocomplete","Title",getArticles,{culture:c,parentId:l,filterTags:s,theme:f!=""?f:null,group:e!=""?e:null,startDate:a,endDate:v});SetSearchboxClickEvent();h=n!=null?n:{culture:c,parentId:l,page:currentPage,query:y,itemsPerPage:t.length?$("#js_items_per_page_list select option:selected").val():8,theme:f!=""?f:null,group:e!=""?e:null,filterTags:s,startDate:a,endDate:v,order:u.find("select option:selected").val()};o.empty();$.ajax({type:"POST",url:"/umbraco/surface/listing/getarticles",data:JSON.stringify(h),dataType:"html",contentType:"application/json",success:function(n){var f=0;n!=null&&n!=""?(o.append(n).hide().fadeIn("slow"),r=$("#js_news_listing_results"),r.length>0?(currentPage=r.data("current-page"),f=r.data("total-pages"),i.text(r.data("results-text")).show(),u.show(),t.length&&t.show(),$(document).foundation("equalizer","reflow")):(i.text(i.data("no-results")).show(),u.hide(),t.length&&t.hide())):(i.text(i.data("no-results")).show(),u.hide(),t.length&&t.hide());helper.initPagination(parseInt(currentPage),parseInt(f),getArticles,h);setNewsFilterData();initSelect2()},error:function(n,r,f){console.log(f);i.text(i.data("no-results")).show();u.hide();t.length&&t.hide()}})}function setNewsFilterData(){var n=$("#js_items_per_page_list"),t={page:currentPage,query:$("#js_search_field").val(),filteringBy:[],itemsPerPage:n.length&&n.find("option:selected").val()!=""?n.find("option:selected").val():8,orderBy:$("#js_results_order select option:selected").val(),from:$("#js_from").val(),to:$("#js_to").val()};$("#js_filtering_by a").each(function(){var n=$(this);t.filteringBy.push("tag"+n.data("tag-id"))});setCookie("filterData",JSON.stringify(t))}function initNewsFilterData(){var t=getCookie("filterData"),n,i;t!=null&&t!=""&&(n=JSON.parse(t),setCookie("filterData",""),currentPage=n.page,$("#js_search_field").val(n.query),$("#js_items_per_page_list select option[value="+n.itemsPerPage+"]").attr("selected","selected"),$("#js_results_order select option[value="+n.order+"]").attr("selected","selected"),$("#js_from").val(n.from),$("#js_to").val(n.to),i=$("#js_filtering_by"),$(n.filteringBy).each(function(){var n=$("#"+this);n.iCheck("check");i.append("<a href=javascript:; class=light-blue data-tag-id="+n.data("tag-id")+">"+n.data("tag-name")+"<\/a>")}))}function SetSearchboxClickEvent(){$("#js_search_field").keyup(function(n){n.keyCode==13&&(currentPage=1,$("#js_search_field").val().trim()!=""&&setCookie("search_query",$("#js_search_field").val().trim()),getArticles(),helper.goToResults())})}$(document).ready(function(){datePicker(getArticles);initNewsFilterData();getArticles();$("#js_use_filter").click(function(){window.location.hash="main_content"});$("#js_search_articles").click(function(){currentPage=1;getArticles();helper.goToResults()});SetSearchboxClickEvent();$("#js_results_order select").change(function(){currentPage=1;getArticles()});$("#js_items_per_page_list select").change(function(){currentPage=1;getArticles()});$("input.js_filter_tag").on("ifChanged",function(){var n=$(this),t=$("#js_filtering_by");n.is(":checked")?t.append("<a href=javascript:; class=light-blue data-tag-id="+n.data("tag-id")+">"+n.data("tag-name")+"<\/a>"):t.children("a[data-tag-id="+n.data("tag-id")+"]").remove();currentPage=1;getArticles()});$("#js_filtering_by").on("click","a",function(){$("#tag"+$(this).data("tag-id")).iCheck("uncheck")})});var currentPage=1