function showmorecomment(page){
	if(jQuery.trim($("#readmore"+page).html()).length){
//		var isVisible=$("#readmore").is(':visible');
//		if(isVisible){
//			$("#readmore").fadeOut("slow");
//		}
//		else{
//			$("#readmore").fadeIn("slow");
//		}
	}
	else{
		$("#readmorelink").fadeOut("slow");
		$.post('/readmorecomment',{page:page},
			function(morecomment){
				$("#readmore"+page).html(morecomment);$("#readmore"+page).fadeIn("slow");
			}
		);
		
	}
}

function showmorepostcomment(postSeq,page){
	if(jQuery.trim($("#view_more_post_comments"+page).html()).length){
//		var isVisible=$("#readmore").is(':visible');
//		if(isVisible){
//			$("#readmore").fadeOut("slow");
//		}
//		else{
//			$("#readmore").fadeIn("slow");
//		}
	}
	else{
		$("#comment_more_div"+page).fadeOut("slow");
		$.post('/ajax/getNextComment.php',{postSeq:postSeq,page:page},
			function(morecomment){
				$("#view_more_post_comments"+page).html(morecomment);$("#view_more_post_comments"+page).fadeIn("slow");
			}
		);
		
	}
}
function showhidesubcomment(seq,postSeq,token,type){
	closeall(seq);
	if(jQuery.trim($("#recomment"+seq).html()).length){
		var isVisible=$("#recomment"+seq).is(':visible');
		if(isVisible){
			$("#recomment"+seq).fadeOut("slow");
			$("#view_all_comment"+seq).fadeOut("slow");
		}
		else{
			$("#recomment"+seq).fadeIn("slow");
			$("#view_all_comment"+seq).fadeIn("slow");
		}
	}
	else{
		$.post('/getsubcomment',{seq:seq,postSeq:postSeq,token:token,type:type},
			function(subcomment){
				$("#recomment"+seq).html(subcomment);$("#recomment"+seq).fadeIn("slow");
			}
		);
	}
}
function showmorecomments(postSeq,token){
	$.post('/getmorecomments',{postSeq:postSeq,token:token},
	function(morecomments){$("#comment_tray"+postSeq).html(morecomments);$("#comment_tray"+postSeq).fadeIn("slow");});
}

function deletecomment(seq,cparent, commentType){

	var yesorno = confirm("削除しますか？");	
	if (yesorno == true) {
		confirmdeletecomment(seq, cparent, commentType);
	}
}

function reportcomment(seq,commenterId){closeall(seq);if($("#comment_report"+seq).length){var isVisible=$("#comment_report"+seq).is(':visible');if(isVisible){$("#comment_report"+seq).fadeOut("slow");$("#reportcomment"+seq).css("color","#748245");}
else{$("#comment_report"+seq).fadeIn("slow");$("#reportcomment"+seq).css("color","#c30");}}
else{$("#comment_edit"+seq).after("<div id='comment_report"+seq+"' class='comment_caution' style='display:none'><strong>本当に通報しますか？</strong> &nbsp; &nbsp; <span class='link' onClick='registercommentreport(1, "+seq+", "+"\""+commenterId+"\""+")'>はい</span> <span class=bar>&nbsp;|&nbsp;</span> <span class='link' onClick=\"$('#comment_report"+seq+"').fadeOut('slow');$('#reportcomment"+seq+"').css('color','#748245');\">いいえ</span> &nbsp; &nbsp; </div>");$("#comment_report"+seq).fadeIn("slow");$("#reportcomment"+seq).css("color","#c30");}}
function registercommentreport(posttype,contentseq,choixerId){$.post('/ajax/report.php',{postOrcomment:posttype,contentSeq:contentseq,choixerId:choixerId},function(subcomment){$("#comment_report"+contentseq).html("<strong>通報しました。</strong>");$("#comment_report"+contentseq).fadeIn("slow");$("#reportcomment"+contentseq).css('color','#748245');setTimeout('$("#comment_report" + '+contentseq+').fadeOut("slow");',3000);});}

function modifycomment(seq,postseq,type){
	closeall(seq);
	if($("#comment_modify"+seq).length){
	var isVisible=$("#comment_modify"+seq).is(':visible');
	if(isVisible){$("#comment_modify"+seq).hide();
	$("#user_comment"+seq).show();
	$("#modifycomment"+seq).css("color","#748245");
}

else{$("#user_comment"+seq).hide();$("#comment_modify"+seq).fadeIn("slow");$("#modifycomment"+seq).css("color","#c30");$("#comment_textarea"+seq).focus();}}
else{$("#user_comment"+seq).hide();$("#user_comment"+seq).after("<div id='comment_modify"+seq+"' style='display:none'><form action='/updatecomment' method='post'><input type='hidden' id='commentSeq"+seq+"' name='commentSeq' value='"+seq+"'><input type='hidden' name='storyid' value='"+postseq+"'><textarea name='comment_modify' id='comment_textarea_modify"+seq+"' class='comment_modify' rows='4' wrap='VIRTUAL' onKeyDown='writecomments_update("+seq+")'>"+$("#comment_body"+seq).text()+"</textarea><div id='nocommentarea_modify"+seq+"' style='float:left; display:none;' class='error_comment'>コメントを入力してください。</div><div class='submit'><input type='submit' class='comment_submit' value='OK' onClick='return checkcomments_update("+seq+");' /><input type='button' class='comment_reset' onClick=\"$('#comment_modify"+seq+"').hide();$('#user_comment"+seq+"').show();$('#modifycomment"+seq+"').css('color','#748245');\" value='キャンセル' /></div><div id='modify_heed' style='display:none'><strong>本当に削除しますか？</strong></div></form></div>");$("#comment_modify"+seq).fadeIn("slow");$("#modifycomment"+seq).css("color","#c30");$("#comment_textarea"+seq).focus();}}
function confirmdeletecomment(seq,cparent,commentType){$("#isCommentType").val(commentType);$("#deleteSeq").val(seq);$("#parentSeq").val(cparent);$("#deleteform").submit();}
function checkcomments_update(seq){if($("#comment_textarea_modify"+seq).val()==""){$("#nocommentarea_modify"+seq).show();return false;}
return true;}
function writecomments_update(seq){if($("#comment_textarea_modify"+seq).val()!="")$("#nocommentarea_modify"+seq).hide();}
function closeall(seq){if($("#recomment"+seq).length){if($("#recomment"+seq).is(':visible'))$("#recomment"+seq).fadeOut("slow");}
if($("#comment_modify"+seq).length){if($("#comment_modify"+seq).is(':visible')){$("#comment_modify"+seq).hide();$("#user_comment"+seq).show();$("#modifycomment"+seq).css("color","#748245");}}
if($("#comment_delete"+seq).length){if($("#comment_delete"+seq).is(':visible')){$("#comment_delete"+seq).fadeOut("slow");$("#deletecomment"+seq).css("color","#748245");}}
if($("#comment_report"+seq).length){if($("#comment_report"+seq).is(':visible')){$("#comment_report"+seq).fadeOut("slow");$("#reportcomment"+seq).css("color","#748245");}}}
function getRelatedPosts(postSeq,ord,level){$.post('/getrelated',{postSeq:postSeq,ord:ord,level:level},function(r){if(r){if(ord==0)$("#related-news").fadeIn("slow");var relatedObj=$("#related-news");if(relatedObj.length)$("#related-news .news-body").prepend(r.contents);if(r.ord<10){relatedposts_timeout_handle=setTimeout("getRelatedPosts("+postSeq+", "+r.ord+", "+r.level+")",1000);}
else $("#related-news .news-body div:last-child").remove();}
else $("#related-news .news-body div:last-child").remove();},"json");}
function onclickCopy(){$("#trackback-url").focus();$("#trackback-url").select();therange=document.getElementById("trackback-url").createTextRange();therange.execCommand("Copy");}


