//JQ 重构, 学习于 log.7thpark.com 等

$(document).ready(function(){

// Ajax Content & font-size
$("body.multi div.openContent").css("display","inline"); // should be block if no IE6
$("h6.fontSize-set").css("display","inline"); // should be block if no IE6

var fontSize=GetCookie("fontSizeDeep");
if (fontSize==null || isNaN(fontSize)){fontSize=1;}
$("div.article-body").each(function(){$(this).css("font-size",fontSize+"em")});
$("h6.fontSize-set a").removeClass("fontSize-sel");
$("h6.fontSize-set a[@rel="+fontSize+"]").addClass("fontSize-sel");

//comments
$("body.multi h6.article-info span.cmtnum").each(function(){
	$(this).text()=="0"?$(this).html(langNoComment):parseInt($(this).text())<2?$(this).html(langOneComment.replace("%n",$(this).text())):parseInt($(this).text())<6?$(this).html(langFewComments.replace("%n",$(this).text())):parseInt($(this).text())<18?$(this).html(langSomeComments.replace("%n",$(this).text())):$(this).html(langMoreComments.replace("%n",$(this).text()));
	$(this).html("<a href=\""+$(this).parent("h6.article-info").parent("div.article-right").children("h2.article-title").children("a").attr("href")+"#comment\">"+$(this).text()+"</a>");
});
$("body.single h6.article-info span.cmtnum").each(function(){
	$(this).text()=="0"?$(this).html(langNoComment):parseInt($(this).text())<2?$(this).html(langOneComment.replace("%n",$(this).text())):parseInt($(this).text())<6?$(this).html(langFewComments.replace("%n",$(this).text())):parseInt($(this).text())<18?$(this).html(langSomeComments.replace("%n",$(this).text())):$(this).html(langMoreComments.replace("%n",$(this).text()));
	$(this).html("<a href=\"#comment\">"+$(this).text()+"</a>");
});

//article edit, comment edit
if (GetCookie("password")){
	$("div.date-box").each(function(){
		$(this).css("cursor","pointer");
		$(this).click(function(){$(this).parent("div.article-left").children("h5.article-edit").slideDown();});
		$(this).parent("div.article-left").hover(function(){null},function(){$(this).children("h5.article-edit").slideUp();});
	});
	$("#msg>ul.msg>li.msgtime>a:hidden").each(function(){
		$(this).css("display","inline");
	});
}

//catalog feed-icon
$("#divCatalog li").each(function(){$(this).text().indexOf(blogTitle)!==-1?$(this).addClass("CurrCate"):null;});

/*
//archives 7thpark.com 原始版本修订 - 隐藏多于两年的
var almax=4; //一直显示的行数, 4 表示 两年, 6 表示三年, 类推.
var alsize=$("#divArchives p").size();
if(alsize>almax){
	for(i=almax;i<alsize;i++){
		$("#divArchives p").eq(i).slideUp();
	}
	$("#divArchives").hover(function(){for(j=almax;j<alsize;j++){$("#divArchives p").eq(j).slideDown();}},function(){for(k=almax;k<alsize;k++){$("#divArchives p").eq(k).slideUp();}});
}
*/
/*
//archives Alt 第二个效果版本 - 隐藏全部月份, 点击任一年全开.
var archsize=$("#divArchives p").size();
for(i=0;i<(parseInt(archsize/2));i++){
	$("#divArchives p").eq(2*i).css("cursor","pointer").addClass("arch-year");
	$("#divArchives p").eq(2*i+1).addClass("arch-month").toggle("normal");
}
$("#divArchives p.arch-year").click(function(){
	$("#divArchives p.arch-month").toggle("normal");
});
*/

//archives Alt  第三个效果版本 - 隐藏除最近一年以外的月份, 点击年打开当年月份.
for(i=0;i<(parseInt($("#divArchives p").size()/2));i++){
	$("#divArchives p").eq(2*i).css("cursor","pointer").addClass("arch-year").attr("id","arch-item"+i);
	$("#divArchives p").eq(2*i+1).addClass("arch-month").attr("id","altarch-item"+i);
	if (i>0){$("#divArchives p").eq(2*i+1).toggle("normal");}
}
$("#divArchives p.arch-year").each(function(){
	$(this).click(function(){
		$(this).parent("div").children("p#alt"+$(this).attr("id")).toggle("normal");
	});
});


//.text
$(".text",$("#divCommentPost")).focus(function(){$(this).addClass("text-focus");}).blur(function(){$(this).removeClass("text-focus");});

//:hover fix for IE6
$("ul.msg").hover(function(){$(this).addClass("box-hover");},function(){$(this).removeClass("box-hover");});
$("ul.ext").hover(function(){$(this).addClass("box-hover");},function(){$(this).removeClass("box-hover");});
$("div.pstwrap").hover(function(){$(this).addClass("box-hover");},function(){$(this).removeClass("box-hover");});
$("div.article-nav").hover(function(){$(this).addClass("box-hover");},function(){$(this).removeClass("box-hover");});

//Tab Roll
if (parseInt(intTabInterval)!==0){
	if ($("#tabPanel").size()>0){
		if (isNaN(intTabInterval) || intTabInterval==""){intTabInterval=8864;}
		if (parseInt(intTabInterval)<999){intTabInterval=999;}
		tabRoll(parseInt(intTabInterval));
		$("#tabPanel").hover(function(){
			tabRollStop();
		},function(){
			tabRoll(parseInt(intTabInterval));
		});
	}
}


});

$(window).load(function(){

// Blockquote Image And External Link
recContent();
// Loaded all elements
$("#pageLoading").fadeOut("slow");

});

// Ctrl+Enter Post
if (document.getElementById("txaArticle"))
{
	document.getElementById("txaArticle").onkeydown = function (moz_ev) {
		var ev = null;
		if (window.event){
			ev = window.event;
		}
		else{
			ev = moz_ev;
		}
		if (ev != null && ev.ctrlKey && ev.keyCode == 13) {
			document.getElementById("submit").click();
			//return VerifyMessage();
		}
	}
}
