!function(){var e=[];window.jQuery&&jQuery(function(t){var a=0,o=t(window),n=1*window._zem_rp_num_rel_posts||5,i=2*n,r=!0,d=t(".zem_rp.related_post"),l=!1,_=!1,p=2*d.outerHeight(!0),s=n,u=function(){if(0>=e.length)return t("#zem_rp_related_load_more").parent().remove(),[];for(var a=0,o=[],d={};(r?n:i)>a;a+=1)(d=e.shift())&&o.push(d);return r=!1,o},m=function(a){_&&0>=e.length&&t("#zem_rp_related_load_more").parent().remove(),!l&&!_&&(l=!0,t.getJSON(window._zem_rp_wp_ajax_url+"?action=zem_rp_load_articles&post_id="+window._zem_rp_post_id+"&from="+s+"&count=50&size=full",function(o){o&&o.length&&"string"!=typeof o?(s+=o.length,t.each(o,function(t,a){e.push(a)}),a&&a()):(_=!0,0>=e.length&&t("#zem_rp_related_load_more").parent().remove()),l=!1}))},c=function(){var a=function(e){setTimeout(function(){t("#zem_rp_related_load_more").find(".zloader").hide().end().find("span").show()},500);var a=t(".related_post.zem_rp"),o=a.find("li ul li").length,n=null,i=a.find(".zem_rp_related_post_column"),r=function(e){var a=t();i.each(function(e,o){o=t("ul",o),(null===a.height()||a.height()>=o.height())&&(a=o)}),a.append(e)};t.each(e,function(e,a){var i=t(a.img);i.load(function(){t(this).data("zloaded",!0)}).error(function(){t(this).data("zloaded",!0)});var d=t('<li data-position="'+o+'" data-poid="'+a.id+'"><a href="'+a.url+'" class="zem_rp_thumbnail"></a><a href="'+a.url+'" class="zem_rp_title">'+a.title+"</a></li>");d.data("position",o),d.data("poid",a.id),d.find(".zem_rp_thumbnail").append(i),o+=1;var l=n;setTimeout(function(){l&&l.length&&!l.data("zloaded")?l.load(function(){r(d,i)}).error(function(){r(d,i)}):r(d,i)},75*e),n=i})};0>=e.length?m(function(){a(u())}):e.length<=2*i?(a(u()),m()):a(u())},f=function(){a&&clearTimeout(a),a=setTimeout(function(){var e=t(".related_post.zem_rp");e.offset().top+e.outerHeight(!0)-o.scrollTop()-o.height()+100<p&&c()},150)};if("undefined"!=typeof window._zem_rp_post_id){var h=-1,z=[],w=0;d.find("li").each(function(e,a){a=t(a),a.children().find("img").data("zloaded",!0);var o=a.data("poid"),n=a.data("position"),i=a.data("post-type"),r=a.attr("class"),o=t('<li class="'+r+'" data-post-type="'+i+'" data-position="'+n+'" data-poid="'+o+'"></li>'),n=a.offset().left;n>h&&(h=n,w+=1),n=e%w,o.append(a.children()),z[n]?(z[n].find("ul").append(o),a.remove()):(a.empty(),a.attr("data-position",null),a.attr("data-poid",null),a.attr("data-post-type",null),a.addClass("zem_rp_related_post_column"),a.addClass("zem_rp_special"),a.append("<ul></ul>"),a.find("ul").append(o),z[n]=a)}),f(),t(window).bind("scroll.zloader",function(){r?f():t(window).unbind("scroll.zloader")}),m(),d.append(t('<li class="zem_rp_related_post_load_more zem_rp_special"><a id="zem_rp_related_load_more" href="#"><span>Load more posts</span><img src="'+window._zem_rp_static_base_url+'img/loading.gif" class="zloader" /></a></li>')),d.find("#zem_rp_related_load_more").click(function(){t("span",this).hide(),t(".zloader",this).show(),c();var e=document.createElement("img"),a={action:"pinterest-load-more",post_id:window._zem_rp_post_id,request_id:window._zem_rp_request_id,_:+new Date},o=[],n=window._zem_rp_static_base_url+"stats.gif?";for(x in a)a.hasOwnProperty(x)&&o.push(x+"="+a[x]);return n+=o.join("&"),e.src=n,!1})}})}();