var _catalog = {
	Line : 0,
	maxLine : 15,
	liHeight : 0,
	showMore: function() {
		if ($('.j-directory').hasClass("more")) {
			$('.j-directory').height(_catalog.liHeight * _catalog.Line);
			$('.j-directory').removeClass("more");
			$(this).html("收起<i class='arrow arrow-up'>&gt;</i>")
		} else {
			$('.j-directory').height(_catalog.liHeight * _catalog.maxLine);
			$('.j-directory').addClass("more");
			$(this).html("更多目录<i class='arrow arrow-down'>&gt;</i>")
		}
	},
	showPart: function() {
		var c;
		if ( this.maxLine > this.Line ){
			$('.j-showmore').hide();
			c = this.liHeight * this.Line
		} else {
			$(".j-showmore").bind('click', this.showMore);
			c = this.liHeight * this.maxLine;
		}
		$('.j-directory').height(c);
	},
	init: function(m) {
		this.maxLine = m;
		this.liHeight = $('.j-directory').find("li").height();
		var i = 0;
		$(".j-directory li").each(function(){
			if ($(this).hasClass("j-volume") && i%2==1) {
				(i%4<2) ? $(this).before("<li class='item j-chapter even'></li>") : $(this).before("<li class='item j-chapter odd'></li>"), i++
			} 
			(i%4<2) ? $(this).addClass('even') : $(this).addClass('odd');
			if ($(this).hasClass("j-volume")) i+=2;
			else {
				if (i%2==1) $(this).addClass('last');
				i++;
			}
		})
		this.Line = Math.ceil(i/2);
		this.showPart();
		$('#J_Fav').bind('click', SAXUE.doFav), $('#J_Top').bind('click', SAXUE.doTop), $('#J_Down').bind('click', SAXUE.doDown), $("#J_Report").bind('click', function(e) {
			e && e.preventDefault();
			SAXUE.Report.showReport(aid,window.location.href)
		});
	}
};

$(function(){
	_catalog.init(10);
	// 百度分享
	if (s_thumb.indexOf("http://")!=0){
		s_thumb = saxue_url + s_thumb
	}
	window._bd_share_config={"common":{"bdSnsKey":{},"bdText":s_intro,"bdUrl":s_url,"bdPic":s_thumb,"bdMini":"2","bdMiniList":false,"bdStyle":"1","bdSize":"16"},"share":{"bdSize":16}};
	with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
})