/*
	--------------------------------
	Infinite Scroll
	--------------------------------
	+ https://github.com/paulirish/infinitescroll
	+ version 2.0b2.110603
	+ Copyright 2011 Paul Irish & Luke Shumard
	+ Licensed under the MIT license
	
	+ Documentation: http://infinite-scroll.com/
	
*/
(function(g,c,i){c.infinitescroll=function(a,b,e){this.element=c(e);this._create(a,b)};c.infinitescroll.defaults={callback:function(){},debug:!1,binder:c(g),nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"<em>Loading the next set of posts...</em>",loadingStart:null,loadingEnd:null,donetext:"<em>Congratulations, you've reached the end of the internet.</em>",navSelector:"div.navigation",contentSelector:null,loadMsgSelector:null,loadingMsgRevealSpeed:"fast",
extraScrollPx:150,itemSelector:"div.post",animate:!1,pathParse:i,dataType:"html",appendCallback:!0,bufferPx:40,orientation:"height",errorCallback:function(){},currPage:1,infid:0,isDuringAjax:!1,isInvalidPage:!1,isDestroyed:!1,isDone:!1,isPaused:!1,pixelsFromNavToBottom:i,pagesLoaded:null,path:i,loadingMsg:i};c.infinitescroll.prototype={_create:function(a,b){var e=this._debug;if(!this._validate(a))return!1;var d=this.options=c.extend({},c.infinitescroll.defaults,a);d.contentSelector=d.contentSelector||
this.element;d.loadMsgSelector=d.loadMsgSelector||d.contentSelector;var f=c(d.nextSelector).attr("href");f?(d.path=this._determinepath(f),d.loadingMsg=c('<div id="infscr-loading"><img alt="Loading..." src="'+d.loadingImg+'" /><div>'+d.loadingText+"</div></div>"),(new Image).src=d.loadingImg,d.pixelsFromNavToBottom=c(document).height()-c(d.navSelector).offset().top,d.callback=b||function(){},this.binding("bind")):e("Navigation selector not found")},_debug:function(){if(this.options.debug)return g.console&&
console.log.call(console,arguments)},_determinepath:function(a){var b=this.options;if(c.isFunction(b.pathParse))return this._debug("pathParse"),[a];else if(a.match(/^(.*?)\b2\b(.*?$)/))a=a.match(/^(.*?)\b2\b(.*?$)/).slice(1);else if(a.match(/^(.*?)2(.*?$)/)){if(a.match(/^(.*?page=)2(\/.*|$)/))return a=a.match(/^(.*?page=)2(\/.*|$)/).slice(1);a=a.match(/^(.*?)2(.*?$)/).slice(1)}else if(a.match(/^(.*?page=)1(\/.*|$)/))return a=a.match(/^(.*?page=)1(\/.*|$)/).slice(1);else 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."),
b.isInvalidPage=!0;this._debug("determinePath",a);return a},_error:function(a){var b=this.options;a!=="destroy"&&a!=="end"&&(a="unknown");this._debug("Error",a);a=="end"&&this._showdonemsg();b.isDone=!0;b.currPage=1;b.isPaused=!1;this.binding("unbind")},_loadcallback:function(a,b){var e=this.options,d=this.options.callback,f;switch(e.isDone?"done":!e.appendCallback?"no-append":"append"){case "done":return this._showdonemsg(),!1;case "no-append":e.dataType=="html"&&(b=c("<div>"+b+"</div>").find(e.itemSelector));
break;case "append":var h=a.children();if(h.length==0)return this._error("end");for(f=document.createDocumentFragment();a[0].firstChild;)f.appendChild(a[0].firstChild);this._debug("contentSelector",c(e.contentSelector)[0]);c(e.contentSelector)[0].appendChild(f);b=h.get()}e.loadingMsg.fadeOut("normal");e.animate&&(f=c(g).scrollTop()+c("#infscr-loading").height()+e.extraScrollPx+"px",c("html,body").animate({scrollTop:f},800,function(){e.isDuringAjax=!1}));if(!e.animate)e.isDuringAjax=!1;d.call(c(e.contentSelector)[0],
b)},_nearbottom:function(){var a=this.options,b=0+c(document).height()-a.binder.scrollTop()-c(g).height();this._debug("math:",b,a.pixelsFromNavToBottom);return b-a.bufferPx<a.pixelsFromNavToBottom},_showdonemsg:function(){var a=this.options;a.loadingMsg.find("img").hide().parent().find("div").html(a.donetext).animate({opacity:1},2E3,function(){c(this).parent().fadeOut("normal")});a.errorCallback()},_validate:function(a){for(var b in a){if(b.indexOf&&b.indexOf("Selector")>-1&&c(a[b]).length===0)return this._debug("Your "+
b+" found no elements."),!1;return!0}},binding:function(a){var b=this;if(a!=="bind"&&a!=="unbind")return this._debug("Binding value  "+a+" not valid"),!1;if(a=="unbind")this.options.binder.unbind("smartscroll.infscr."+b.options.infid);else this.options.binder[a]("smartscroll.infscr."+b.options.infid,function(){b.setup()});this._debug("Binding",a)},destroy:function(){this.options.isDestroyed=!0;return this._error("destroy")},pause:function(a){var b=this.options;a!=="pause"&&a!=="resume"&&a!=="toggle"&&
a!==null&&this._debug("Invalid argument. Toggling pause value instead");switch(a&&(a=="pause"||a=="resume")?a:"toggle"){case "pause":b.isPaused=!0;break;case "resume":b.isPaused=!1;break;case "toggle":b.isPaused=!b.isPaused}this._debug("Paused",b.isPaused);return!1},retrieve:function(){var a=this,b=a.options,e=b.path,d,f,h,g;if(b.isDestroyed)return this._debug("Instance already destroyed"),!1;b.isDuringAjax=!0;b.loadingMsg.appendTo(b.loadMsgSelector).show(b.loadingMsgRevealSpeed,function(){c(b.navSelector).hide();
b.currPage++;a._debug("heading into ajax",e);d=c(b.contentSelector).is("table")?c("<tbody/>"):c("<div/>");f=c.isFunction(b.pathParse)?b.pathParse(e.join("2"),b.currPage):e.join(b.currPage);h=b.dataType=="html"||b.dataType=="json"?b.dataType:"html+callback";b.appendCallback&&b.dataType=="html"&&(h+="+callback");switch(h){case "html+callback":a._debug("Using HTML via .load() method");d.load(f+" "+b.itemSelector,null,function(b){a._loadcallback(d,b.responseText)});break;case "html":case "json":a._debug("Using "+
h.toUpperCase()+" via $.ajax() method"),c.ajax({url:f,dataType:b.dataType,complete:function(b,c){(g=typeof b.isResolved!=="undefined"?b.isResolved():c==="success"||c==="notmodified")?a._loadcallback(d,b.responseText):a._error("end")}})}})},setup:function(){var a=this.options;!a.isDuringAjax&&!a.isInvalidPage&&!a.isDone&&!a.isDestroyed&&!a.isPaused&&this._nearbottom()&&this.retrieve()}};c.fn.infinitescroll=function(a,b){switch(typeof a){case "string":var e=Array.prototype.slice.call(arguments,1),d=
function(){return g.console&&console.log.call(console,arguments)};this.each(function(){var b=c.data(this,"infinitescroll");if(!b)return d("Method "+a+" cannot be called until Infinite Scroll is setup"),!1;if(!c.isFunction(b[a])||a.charAt(0)==="_")return d("No such method "+a+" for Infinite Scroll"),!1;b[a].apply(b,e)});break;case "object":this.each(function(){c.data(this,"infinitescroll")||c.data(this,"infinitescroll",new c.infinitescroll(a,b,this))})}return this};var j=c.event,k;j.special.smartscroll=
{setup:function(){c(this).bind("scroll",j.special.smartscroll.handler)},teardown:function(){c(this).unbind("scroll",j.special.smartscroll.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartscroll";k&&clearTimeout(k);k=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}};c.fn.smartscroll=function(a){return a?this.bind("smartscroll",a):this.trigger("smartscroll",["execAsap"])}})(window,jQuery);
