!function(e,i,t){"use strict";i.infinitescroll=function(e,t,o){this.element=i(o),this._create(e,t)||(this.failed=!0)},i.infinitescroll.defaults={loading:{finished:void 0,finishedMsg:"All items loaded",img:"",msg:null,msgText:"",selector:null,speed:"fast",start:void 0},state:{isDuringAjax:!1,isInvalidPage:!1,isDestroyed:!1,isDone:!1,isPaused:!1,currPage:1},debug:!1,behavior:void 0,binder:i(e),nextSelector:"div#pagination a:first",navSelector:"div#pagination",contentSelector:null,extraScrollPx:150,itemSelector:".post",animate:!1,pathParse:void 0,dataType:"html",appendCallback:!0,bufferPx:40,errorCallback:function(){},infid:0,pixelsFromNavToBottom:void 0,path:void 0,prefill:!1,maxPage:void 0},i.infinitescroll.prototype={_binding:function(e){var i=this,t=i.options;if(t.v="2.0b2.120520",t.behavior&&void 0!==this["_binding_"+t.behavior])this["_binding_"+t.behavior].call(this);else{if("bind"!==e&&"unbind"!==e)return this._debug("Binding value  "+e+" not valid"),!1;"unbind"===e?this.options.binder.unbind("smartscroll.infscr."+i.options.infid):this.options.binder[e]("smartscroll.infscr."+i.options.infid,function(){i.scroll()}),this._debug("Binding",e)}},_create:function(t,o){var n=i.extend(!0,{},i.infinitescroll.defaults,t);this.options=n;var a=i(e);if(!this._validate(t))return!1;var s=i(n.nextSelector).attr("href");if(!s)return this._debug("Navigation selector not found"),!1;n.path=n.path||this._determinepath(s),n.contentSelector=n.contentSelector||this.element,n.loading.selector=n.loading.selector||n.contentSelector;var r=i("body").hasClass("ascend")||i("body").hasClass("material")?'<span class="default-loading-icon spin"></span>':"",l=i("body").hasClass("ascend")||i("body").hasClass("material")?"default_loader ":"";n.loading.msg=n.loading.msg||i('<div class="infscr-loading-wrap"><div id="infscr-loading" class='+l+'><img alt="Loading..." src="'+n.loading.img+'" /> '+r+" <div>"+n.loading.msgText+"</div></div></div>"),(new Image).src=n.loading.img,void 0===n.pixelsFromNavToBottom&&(n.pixelsFromNavToBottom=i(document).height()-i(n.navSelector).offset().top);var c=this;if(i(".post-area.infinite_scroll").length>0)if(i(".post-area.infinite_scroll.span_9").length>0)var d="#sidebar";else d=".post-area.infinite_scroll";else d=".portfolio-items.infinite_scroll";return n.loading.start=n.loading.start||function(){n.loading.msg.insertAfter(d).show(0,i.proxy(function(){this.beginAjax(n)},c)).transition({scale:1,opacity:1,height:60,"padding-top":35,"padding-bottom":35},400,"easeOutCubic")},n.loading.finished=n.loading.finished||function(){n.loading.msg.stop().transition({scale:.5,opacity:0},400,"easeOutCubic")},n.callback=function(e,t,s){n.behavior&&void 0!==e["_callback_"+n.behavior]&&e["_callback_"+n.behavior].call(i(n.contentSelector)[0],t,s),o&&o.call(i(n.contentSelector)[0],t,n,s),n.prefill&&a.bind("resize.infinite-scroll",e._prefill)},t.debug&&(!Function.prototype.bind||"object"!=typeof console&&"function"!=typeof console||"object"!=typeof console.log||["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.call(console[e],console)},Function.prototype.bind)),this._setup(),n.prefill&&this._prefill(),i(".portfolio-wrap, .post-area.masonry").css("margin-bottom",0),!0},_prefill:function(){var t=this,o=i(document),n=i(e);function a(){return o.height()<=n.height()}this._prefill=function(){a()&&t.scroll(),n.bind("resize.infinite-scroll",function(){a()&&(n.unbind("resize.infinite-scroll"),t.scroll())})},this._prefill()},_debug:function(){!0===this.options.debug&&("undefined"!=typeof console&&"function"==typeof console.log?1===Array.prototype.slice.call(arguments).length&&"string"==typeof Array.prototype.slice.call(arguments)[0]?console.log(Array.prototype.slice.call(arguments).toString()):console.log(Array.prototype.slice.call(arguments)):Function.prototype.bind||"undefined"==typeof console||"object"!=typeof console.log||Function.prototype.call.call(console.log,console,Array.prototype.slice.call(arguments)))},_determinepath:function(e){var i=this.options;if(i.behavior&&void 0!==this["_determinepath_"+i.behavior])return this["_determinepath_"+i.behavior].call(this,e);if(i.pathParse)return this._debug("pathParse manual"),i.pathParse(e,this.options.state.currPage+1);if(e.match(/^(.*?)\b2\b(.*?$)/))e=e.match(/^(.*?)\b2\b(.*?$)/).slice(1);else if(e.match(/^(.*?)2(.*?$)/)){if(e.match(/^(.*?page=)2(\/.*|$)/))return e=e.match(/^(.*?page=)2(\/.*|$)/).slice(1);e=e.match(/^(.*?)2(.*?$)/).slice(1)}else{if(e.match(/^(.*?page=)1(\/.*|$)/))return e=e.match(/^(.*?page=)1(\/.*|$)/).slice(1);this._debug("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com."),i.state.isInvalidPage=!0}return this._debug("determinePath",e),e},_error:function(e){var i=this.options;i.behavior&&void 0!==this["_error_"+i.behavior]?this["_error_"+i.behavior].call(this,e):("destroy"!==e&&"end"!==e&&(e="unknown"),this._debug("Error",e),"end"===e&&this._showdonemsg(),i.state.isDone=!0,i.state.currPage=1,i.state.isPaused=!1,this._binding("unbind"))},_loadcallback:function(t,o,n){var a,s=this.options,r=this.options.callback,l=s.state.isDone?"done":s.appendCallback?"append":"no-append";if(s.behavior&&void 0!==this["_loadcallback_"+s.behavior])this["_loadcallback_"+s.behavior].call(this,t,o);else{switch(l){case"done":return this._showdonemsg(),!1;case"no-append":"html"===s.dataType&&(o=i(o="<div>"+o+"</div>").find(s.itemSelector));break;case"append":var c=t.children();if(0===c.length)return this._error("end");for(a=document.createDocumentFragment();t[0].firstChild;)a.appendChild(t[0].firstChild);this._debug("contentSelector",i(s.contentSelector)[0]),i(s.contentSelector)[0].appendChild(a),o=c.get()}if(s.loading.finished.call(i(s.contentSelector)[0],s),s.animate){var d=i(e).scrollTop()+i("#infscr-loading").height()+s.extraScrollPx+"px";i("html,body").animate({scrollTop:d},800,function(){s.state.isDuringAjax=!1})}s.animate||(s.state.isDuringAjax=!1),r(this,o,n),s.prefill&&this._prefill()}},_nearbottom:function(){var t=this.options;i(document).height(),i(e).scrollTop(),i(e).height();return t.pixelsFromNavToBottom=i(t.navSelector).offset().top,i(e).scrollTop()+i(e).height()+800>t.pixelsFromNavToBottom},_pausing:function(e){var i=this.options;if(!i.behavior||void 0===this["_pausing_"+i.behavior]){switch("pause"!==e&&"resume"!==e&&null!==e&&this._debug("Invalid argument. Toggling pause value instead"),e=!e||"pause"!==e&&"resume"!==e?"toggle":e){case"pause":i.state.isPaused=!0;break;case"resume":i.state.isPaused=!1;break;case"toggle":i.state.isPaused=!i.state.isPaused}return this._debug("Paused",i.state.isPaused),!1}this["_pausing_"+i.behavior].call(this,e)},_setup:function(){var e=this.options;if(!e.behavior||void 0===this["_setup_"+e.behavior])return this._binding("bind"),!1;this["_setup_"+e.behavior].call(this)},_showdonemsg:function(){var e=this.options;e.behavior&&void 0!==this["_showdonemsg_"+e.behavior]?this["_showdonemsg_"+e.behavior].call(this):(e.loading.msg.find("img, .default-loading-icon").hide().parent().find("div").html(i("#pagination").attr("data-is-text")).animate({opacity:1},500,function(){i(this).parent().delay(2100).transition({scale:.4,opacity:0},500,"easeOutCubic"),i(this).parent().parent().delay(2100).animate({height:"0",padding:0},500,"easeOutCubic")}),e.loading.msg.find("#infscr-loading").css({height:"auto",width:"auto",padding:"13px 17px","background-image":"none","border-width":"2px"}),e.errorCallback.call(i(e.contentSelector)[0],"done"))},_validate:function(e){for(var t in e)if(t.indexOf&&t.indexOf("Selector")>-1&&0===i(e[t]).length)return this._debug("Your "+t+" found no elements."),!1;return!0},bind:function(){this._binding("bind")},destroy:function(){return this.options.state.isDestroyed=!0,this.options.loading.finished(),this._error("destroy")},pause:function(){this._pausing("pause")},resume:function(){this._pausing("resume")},beginAjax:function(e){var t,o,n,a,s=this,r=e.path;if(e.state.currPage++,null!=e.maxPage&&e.state.currPage>e.maxPage)this.destroy();else switch(t=i(e.contentSelector).is("table")?i("<tbody/>"):i("<div/>"),o="function"==typeof r?r(e.state.currPage):r.join(e.state.currPage),s._debug("heading into ajax",o),n="html"===e.dataType||"json"===e.dataType?e.dataType:"html+callback",e.appendCallback&&"html"===e.dataType&&(n+="+callback"),n){case"html+callback":s._debug("Using HTML via .load() method"),t.load(o+" "+e.itemSelector,void 0,function(e){s._loadcallback(t,e,o)});break;case"html":s._debug("Using "+n.toUpperCase()+" via $.ajax() method"),i.ajax({url:o,dataType:e.dataType,complete:function(e,i){(a=void 0!==e.isResolved?e.isResolved():"success"===i||"notmodified"===i)?s._loadcallback(t,e.responseText,o):s._error("end")}});break;case"json":s._debug("Using "+n.toUpperCase()+" via $.ajax() method"),i.ajax({dataType:"json",type:"GET",url:o,success:function(i,n,r){if(a=void 0!==r.isResolved?r.isResolved():"success"===n||"notmodified"===n,e.appendCallback)if(void 0!==e.template){var l=e.template(i);t.append(l),a?s._loadcallback(t,l):s._error("end")}else s._debug("template must be defined."),s._error("end");else a?s._loadcallback(t,i,o):s._error("end")},error:function(){s._debug("JSON ajax request failed."),s._error("end")}})}},retrieve:function(e){e=e||null;var t=this.options;if(t.behavior&&void 0!==this["retrieve_"+t.behavior])this["retrieve_"+t.behavior].call(this,e);else{if(t.state.isDestroyed)return this._debug("Instance is destroyed"),!1;t.state.isDuringAjax=!0,t.loading.start.call(i(t.contentSelector)[0],t)}},scroll:function(){var e=this.options,i=e.state;e.behavior&&void 0!==this["scroll_"+e.behavior]?this["scroll_"+e.behavior].call(this):i.isDuringAjax||i.isInvalidPage||i.isDone||i.isDestroyed||i.isPaused||this._nearbottom()&&this.retrieve()},toggle:function(){this._pausing()},unbind:function(){this._binding("unbind")},update:function(e){i.isPlainObject(e)&&(this.options=i.extend(!0,this.options,e))}},i.fn.infinitescroll=function(e,t){switch(typeof e){case"string":var o=Array.prototype.slice.call(arguments,1);this.each(function(){var t=i.data(this,"infinitescroll");return!!t&&(!(!i.isFunction(t[e])||"_"===e.charAt(0))&&void t[e].apply(t,o))});break;case"object":this.each(function(){var o=i.data(this,"infinitescroll");o?o.update(e):(o=new i.infinitescroll(e,t,this)).failed||i.data(this,"infinitescroll",o)})}return this};var o,n=i.event;n.special.smartscroll={setup:function(){i(this).bind("scroll",n.special.smartscroll.handler)},teardown:function(){i(this).unbind("scroll",n.special.smartscroll.handler)},handler:function(e,t){var n=this,a=arguments;e.type="smartscroll",o&&clearTimeout(o),o=setTimeout(function(){i(n).trigger("smartscroll",a)},"execAsap"===t?0:100)}},i.fn.smartscroll=function(e){return e?this.bind("smartscroll",e):this.trigger("smartscroll",["execAsap"])}}(window,jQuery);