/*!
 * @version   $Id: gantry-morearticles.js 3126 2012-09-03 19:18:21Z btowles $
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */
var GantryMoreArticles=new Class({Implements:[Options],options:{leadings:2,moreText:"more articles",url:""},initialize:function(a){this.setOptions(a);
this.wrapper=document.getElements(".blog-featured .items-row")||document.getElements(".blog .items-row")||document.getElement(".items-leading");if(!this.wrapper||!this.wrapper.length){return;
}if(this.wrapper.length){this.wrapper=this.wrapper.getLast();}this.start=this.options.leadings;this.buildButton();this.ajax=new Request({url:this.options.url,method:"get",onRequest:function(){this.button.addClass("spinner");
}.bind(this),onSuccess:this.handle.bind(this)});},buildButton:function(){this.button=new Element("a",{id:"more-articles",href:"#"}).adopt(new Element("span").set("text",this.options.moreText));
var a=new Element("div",{"class":"rt-more-articles"}).inject(this.wrapper,"after");this.button.inject(a).addEvent("click",function(b){b.stop();if(this.button.hasClass("disabled")){return;
}this.ajax.get({limitstart:this.start});}.bind(this));},handle:function(e){this.start+=this.options.leadings;this.button.removeClass("spinner");var b=new Element("div").set("html",e);
var d=b.getElements(".items-leading > div, .item");if(!d.length){this.button.removeEvent("click");this.button.addClass("disabled");}else{if(d.length<this.options.leadings){this.button.removeEvent("click");
this.button.addClass("disabled");}d.inject(this.wrapper,"after");if(typeof GantryBuildSpans=="function"){var a=["rt-block"];var c=["h3","h2","h1"];GantryBuildSpans(a,c);
}if(typeof GantryArticleDetails!="undefined"){GantryArticleDetails.init();}}if(typeof rokbox!="undefined"&&rokbox.refresh){rokbox.refresh();}}});