/*
// Infinite Scroll jQuery plugin
// copyright Paul Irish, licensed GPL & MIT
// version 1.4.100210

// home and docs: http://www.infinite-scroll.com
*/
(function(A){A.fn.infinitescroll=function(Q,O){function E(){if(B.debug){window.console&&console.log.call(console,arguments)}}function H(S){for(var R in S){if(R.indexOf&&R.indexOf("Selector")>-1&&A(S[R]).length===0){E("Your "+R+" found no elements.");return false}return true}}function N(R){R.match(C)?R.match(C)[2]:R;if(R.match(/^(.*?)\b2\b(.*?$)/)){R=R.match(/^(.*?)\b2\b(.*?$)/).slice(1)}else{if(R.match(/^(.*?)2(.*?$)/)){if(R.match(/^(.*?page=)2(\/.*|$)/)){R=R.match(/^(.*?page=)2(\/.*|$)/).slice(1);return R}E("Trying backup next selector parse technique. Treacherous waters here, matey.");R=R.match(/^(.*?)2(.*?$)/).slice(1)}else{E("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.");K.isInvalidPage=true}}return R}function L(){return B.localMode?(A(K.container)[0].scrollHeight&&A(K.container)[0].scrollHeight):A(document).height()}function F(){var R=0+L()-(B.localMode?A(K.container).scrollTop():(A(K.container).scrollTop()||A(K.container.ownerDocument.body).scrollTop()))-A(B.localMode?K.container:window).height();E("math:",R,K.pixelsFromNavToBottom);return(R-B.bufferPx<K.pixelsFromNavToBottom)}function M(){K.loadingMsg.find("img").hide().parent().find("div").html(B.donetext).animate({opacity:1},2000).fadeOut("normal");B.errorCallback()}function D(){if(K.isDuringAjax||K.isInvalidPage||K.isDone){return }if(!F(B,K)){return }A(document).trigger("retrieve.infscr")}function G(){K.isDuringAjax=true;K.loadingMsg.appendTo(B.contentSelector).show();A(B.navSelector).hide();K.currPage++;E("heading into ajax",P);J=A(B.contentSelector).is("table")?A("<tbody/>"):A("<div/>");J.attr("id","infscr-page-"+K.currPage).addClass("infscr-pages").appendTo(B.contentSelector).load(P.join(K.currPage)+" "+B.itemSelector,null,I)}function I(){if(K.isDone){M();return false}else{if(J.children().length==0){A.event.trigger("ajaxError",[{status:404}])}K.loadingMsg.fadeOut("normal");if(B.animate){var R=A(window).scrollTop()+A("#infscr-loading").height()+B.extraScrollPx+"px";A("html,body").animate({scrollTop:R},800,function(){K.isDuringAjax=false})}O.call(J[0]);if(!B.animate){K.isDuringAjax=false}}}var B=A.extend({},A.infinitescroll.defaults,Q),K=A.infinitescroll,J;O=O||function(){};if(!H(B)){return false}K.container=B.localMode?this:document.documentElement;B.contentSelector=B.contentSelector||this;var C=/(.*?\/\/).*?(\/.*)/,P=A(B.nextSelector).attr("href");if(!P){E("Navigation selector not found");return }P=N(P);if(B.localMode){A(K.container)[0].scrollTop=0}K.pixelsFromNavToBottom=L()+(K.container==document.documentElement?0:A(K.container).offset().top)-A(B.navSelector).offset().top;K.loadingMsg=A('<div id="infscr-loading" style="text-align: center;"><center><img alt="Loading..." src="'+B.loadingImg+'" /><div>'+B.loadingText+"</div></center></div>");(new Image()).src=B.loadingImg;A(document).ajaxError(function(S,T,R){E("Page not found. Self-destructing...");if(T.status==404){M();K.isDone=true;A(B.localMode?this:window).unbind("scroll.infscr")}});A(B.localMode?this:window).bind("scroll.infscr",D).trigger("scroll.infscr");A(document).bind("retrieve.infscr",G);return this};A.infinitescroll={defaults:{debug:false,preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"<em>Loading the next set of posts...</em>",donetext:"<em>Congratulations, you've reached the end of the internet.</em>",navSelector:"div.navigation",contentSelector:null,extraScrollPx:150,itemSelector:"div.post",animate:false,localMode:false,bufferPx:40,errorCallback:function(){}},loadingImg:undefined,loadingMsg:undefined,container:undefined,currPage:1,currDOMChunk:null,isDuringAjax:false,isInvalidPage:false,isDone:false}})(jQuery);