function RollingArchives(b){RA=this;RA.content=b.content;RA.posts=b.posts;RA.parent=b.parent;RA.offsetTop=b.offset||0;RA.cache=new Array();RA.cacheDepth=b.cachedepth||5;RA.pageText=b.pagetext||"of";var c=b.older||"Older";var a=b.newer||"Newer";var d=b.loading||"Loading";jQuery(RA.content).before('		<div id="rollingarchivesbg"></div>		<div id="rollingarchives">			<div id="rollnavigation">				<div id="pagetrackwrap"><div id="pagetrack"><div id="pagehandle"><div id="rollhover"><div id="rolldates"></div></div></div></div></div>								<div id="rollpages"></div>								<a id="rollprevious" title="'+c+'" href="#"><span>&laquo;</span> '+c+'</a>				<div id="rollload" title="'+d+'"><span>'+d+'</span></div>				<a id="rollnext" title="'+a+'" href="#">'+a+' <span>&raquo;</span></a>								<div id="texttrimmer">					<div id="trimmertrim"><span>&raquo;&nbsp;&laquo;</span></div>					<div id="trimmeruntrim"><span>&laquo;&nbsp;&raquo;</span></div>				</div>			</div> <!-- #rollnavigation -->		</div> <!-- #rollingarchives -->	');
RA.setState(b.pagenumber,b.pagecount,b.query,b.pagedates);RA.saveState();jQuery("#rollnext").click(function(){RA.pageSlider.setValueBy(1);return false});jQuery("#rollprevious").click(function(){RA.pageSlider.setValueBy(-1);return false});jQuery("#trimmertrim, #trimmeruntrim").click(function(){if(K2.Animations){jQuery(".entry-content").slideToggle(250,"easeOutExpo")}jQuery("body").toggleClass("trim")});RA.assignHotkeys();jQuery("body").addClass("rollingarchives");RA.smartPosition(RA.parent)}RollingArchives.prototype.setState=function(a,c,b,d){RA.pageNumber=a;
RA.pageCount=c;RA.query=b;RA.pageDates=d;if(RA.validatePage(RA.pageNumber)){jQuery("body").removeClass("hiderollingarchives").addClass("showrollingarchives");jQuery("#rollingarchives").show();jQuery("#rollload, #rollhover").hide();RA.pageSlider=new K2Slider("#pagehandle","#pagetrackwrap",{minimum:1,maximum:RA.pageCount,value:RA.pageCount-RA.pageNumber+1,onSlide:function(e){jQuery("#rollhover").show();RA.updatePageText(RA.pageCount-e+1)},onChange:function(e){RA.updatePageText(RA.pageCount-e+1);RA.gotoPage(RA.pageCount-e+1)
}});RA.updatePageText(RA.pageNumber)}else{jQuery("body").removeClass("showrollingarchives").addClass("hiderollingarchives")}RA.resetCache()};RollingArchives.prototype.saveState=function(){RA.prevPageNumber=RA.pageNumber;RA.prevPageCount=RA.pageCount;RA.prevQuery=RA.query;RA.prevPageDates=RA.pageDates;RA.prevContent=jQuery(RA.content).html()};RollingArchives.prototype.restoreState=function(){if(RA.prevContent!=""){jQuery("body").removeClass("livesearchactive").addClass("livesearchinactive");jQuery(RA.content).html(RA.prevContent);
jQuery.bbq.pushState("#page="+RA.prevPageNumber);RA.setState(RA.prevPageNumber,RA.prevPageCount,RA.prevQuery,RA.prevPageDates)}};RollingArchives.prototype.updatePageText=function(a){jQuery("#rollpages").html(a+" "+RA.pageText+" "+RA.pageCount);jQuery("#rolldates").html(RA.pageDates[a-1])};RollingArchives.prototype.validatePage=function(a){var a=parseInt(a);if(!isNaN(a)&&RA.pageCount>1){if(a>=RA.pageCount){jQuery("body").removeClass("onepageonly firstpage nthpage").addClass("lastpage");return RA.pageCount
}else{if(a<=1){jQuery("body").removeClass("onepageonly nthpage lastpage").addClass("firstpage");return 1}else{jQuery("body").removeClass("onepageonly firstpage lastpage").addClass("nthpage");return a}}}jQuery("body").removeClass("firstpage nthpage lastpage").addClass("onepageonly");return 0};RollingArchives.prototype.loading=function(a){if(a=="start"){jQuery("body").addClass("rollload")}else{jQuery("body").removeClass("rollload")}};RollingArchives.prototype.gotoPage=function(b){var a=RA.validatePage(b);
if(a!=RA.pageNumber&&a!=0){RA.lastPage=RA.pageNumber;RA.pageNumber=a;jQuery.bbq.pushState("page="+a);RA.loading("start");if(K2.Animations){RA.flashElement(a>RA.lastPage?"#rollprevious":"#rollnext")}if(K2.Animations&&(RA.pageNumber!=1)&&jQuery("body").hasClass("smartposition")){jQuery("html,body").animate({scrollTop:jQuery(RA.parent).offset().top},100)}jQuery.extend(RA.query,{paged:RA.pageNumber,k2dynamic:1});if(RA.cache[RA.pageNumber]==undefined){K2.ajaxGet(RA.query,function(d){jQuery("#rollhover").fadeOut("slow");
RA.loading("stop");jQuery(RA.content).html(d)})}else{jQuery("#rollhover").fadeOut("slow");RA.loading("stop");jQuery(RA.content).html(RA.cache[RA.pageNumber])}RA.updateCache()}if(a==1){jQuery("body").removeClass("trim");var c=jQuery(window).scrollTop();jQuery.bbq.removeState("page");jQuery(window).scrollTop(c)}};RollingArchives.prototype.resetCache=function(){RA.cache=new Array()};RollingArchives.prototype.updateCache=function(){var d=RA.pageNumber-RA.cacheDepth;var c=RA.pageNumber+RA.cacheDepth;if(d<1){d=1
}if(c>RA.pageCount){c=RA.pageCount}for(var b=d;b<=c;b++){if(b==RA.pageNumber){continue}if(RA.cache[b]==undefined){jQuery.extend(RA.query,{paged:b,k2dynamic:1});(function(e){K2.ajaxGet(RA.query,function(f){RA.cache[e]=f})})(b)}}if(RA.cache.length>0){for(var a=0;a<RA.cache.length;a++){if(a>=(d-1)&&a<=(c+1)){continue}delete RA.cache[a]}}};RollingArchives.prototype.smartPosition=function(b,a){RA.parentTop=jQuery(b).offset().top;RA.smartPosClass="smartposition";if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)<7){return
}if(a!="bottom"){setTimeout(RA.checkTop,100);jQuery(window).scroll(RA.checkTop)}else{setTimeout(RA.checkTop,100);jQuery(window).scroll(RA.checkBottom).resize(RA.checkBottom).onload(RA.checkBottom)}};RollingArchives.prototype.checkBottom=function(){if((document.documentElement.scrollTop+document.documentElement.clientHeight||document.body.scrollTop+document.documentElement.clientHeight)>=RA.parentTop&&jQuery("body").hasClass("showrollingarchives")){jQuery("body").addClass(RA.smartPosClass)}else{jQuery("body").removeClass(RA.smartPosClass)
}};RollingArchives.prototype.checkTop=function(){if(jQuery(document).scrollTop()>=RA.parentTop&&jQuery("body").hasClass("showrollingarchives")){jQuery("body").addClass(RA.smartPosClass)}else{jQuery("body").removeClass(RA.smartPosClass)}};RollingArchives.prototype.scrollTo=function(b,d,a){jQuery(window).unbind("scroll.scrolldetector");jQuery("html, body").stop();RA.nextIndex=(a!=undefined?a:RA.nextIndex);if(RA.nextIndex==undefined){jQuery(b).each(function(f){if(jQuery(this).offset().top-RA.offset>jQuery(window).scrollTop()){RA.nextIndex=(d===1?f-1:f);
return false}})}if(d===-1&&RA.pageNumber===1&&RA.nextIndex===0){return}RA.nextIndex=RA.nextIndex+d;if((RA.nextIndex>jQuery(b).length-1)||RA.nextIndex<0){RA.nextIndex=undefined;RA.pageSlider.setValueBy(-d);RA.flashElement(d===1?"#rollprevious":"#rollnext")}RA.nextElement=jQuery(b).eq(RA.nextIndex);var e=RA.nextElement.offset().top-RA.offset;var c=(jQuery.browser.safari)?jQuery("body"):jQuery("html");c.animate({scrollTop:e},(K2.Animations?150:0),"easeOutExpo",function(){RA.nextElement.effect("highlight",{color:"#dddddd"},1500)
})};RollingArchives.prototype.flashElement=function(b){if(jQuery(b+":animated").length>0||!K2.Animations){return}var a=parseInt(jQuery(b).css("font-size"));jQuery(b).animate({fontSize:a*2},0,"linear",function(){jQuery(b).animate({fontSize:a},150,"easeOutQuad")})};RollingArchives.prototype.assignHotkeys=function(){jQuery(document).bind("keydown.hotkeys","J",function(){RA.scrollTo(RA.posts,1)});jQuery(document).bind("keydown.hotkeys","K",function(){RA.scrollTo(RA.posts,-1)});jQuery(document).bind("keydown.hotkeys","Return",function(){if(jQuery(RA.nextElement).length>0){jQuery(RA.nextElement).stop(true,true).effect("highlight",{color:"#eee"},150).children(".entry-title a").click()
}});jQuery(document).bind("keydown.hotkeys","E",function(){if(jQuery(".selected").length>0){jQuery(".selected a.post-edit-link").click();RA.flashElement(".selected a.post-edit-link")}});jQuery(document).bind("keydown.hotkeys","Esc",function(){jQuery(window).unbind("scroll.scrolldetector");jQuery("*").removeClass("selected");RA.nextIndex=undefined});jQuery(document).bind("keydown.hotkeys","H",function(){RA.gotoPage(1)});jQuery(document).bind("keydown.hotkeys","T",function(){jQuery("#texttrimmer div:visible").click()
});jQuery(document).bind("keydown.hotkeys","Left",function(){RA.pageSlider.setValueBy(-1)});jQuery(document).bind("keydown.hotkeys","Right",function(){RA.pageSlider.setValueBy(1)})};