﻿function selectDate(theme_id,year,month){
	var options = {asynchronous:true,
				   evalScripts:true};
	new Ajax.Updater('blog_content','/ajax/select_date/'+theme_id+'/'+year+'/'+month ,options);
}

function selectDatePage(blog_id,page){
	var options = {asynchronous:true,
				   evalScripts:true};
	new Ajax.Updater('date_selection','/ajax/select_date_page/'+blog_id+'/'+page,options);
}

function selectThemePage(blog_id,theme_id,select_by,page , article_id_list_str){
	var options = {asynchronous:true,
				   evalScripts:true};
	new Ajax.Updater('theme_selection','/ajax/select_theme_page/'+blog_id+'/'+theme_id+'/'+select_by+'/'+page+'/'+article_id_list_str,options);
}

function selectTheme(select_by,theme_id ,page){
	var options = {asynchronous:true,
				   evalScripts:true};
	hideDetail();
	new Ajax.Updater('blog_content','/ajax/select_theme/'+select_by+'/'+theme_id+'/'+page,options);
}

function selectArticle(article_id ,blog_id,theme_id,select_by,page){
	selectThemePage(blog_id,theme_id,select_by, page , article_id);
	viewArticleComment(article_id , 1)
}

function viewArticleComment(article_id , page){
	var options = {asynchronous:true,
				   evalScripts:true};
	//alert(article_id);
	new Ajax.Updater('view_detail','/ajax/view_article_comment/'+article_id,options+"/"+page);	
}

function selectCommentPage(article_id , page){
	var options = {asynchronous:true,
				   evalScripts:true};
	new Ajax.Updater('blog_comment','/ajax/select_comment_page/'+article_id+"/"+page,options);
}

function checkLogin(){
	if (document.getElementById('commentText')){
		if (document.getElementById('commentText').value.length <= 0){
			alert('请输入所有必须填写的项目');
		}
		else {
			var options = {asynchronous:true, 
							evalScripts:true};
			new Ajax.Updater('login_result','/php/is_login.php',options);
		}
	}
}
function login_success(){
	document.NewComment.submit();
}
function login_required(){
	alert('Must login before add comment');
}
/*
function updateComments(blog_id){
	var options = {asynchronous:true, 
		   evalScripts:true};
	new Ajax.Updater('last_comments','/ajax/update_comments/'+blog_id,options);
}
*/
function hideDetail(){
	document.getElementById('view_detail').style.display = "none";
	document.getElementById('blog_content').style.display = "inline";
}

function showDetail(){
	document.getElementById('blog_content').style.display = "none";
	document.getElementById('view_detail').style.display = "inline";
}

function copyBlogLink(id){
	//alert(id);
	var copyText = document.getElementById('copyText'+id);
	r=copyText.createTextRange(); 
	r.select(); 
	r.execCommand('copy'); 
}

function selectUserArticle(theme_id , user_id ,page){
	var options = {asynchronous:true,
				   evalScripts:true,
				   onComplete:function(){hideDetail();}};
	new Ajax.Updater('blog_content','/ajax/select_user_article/'+theme_id+'/'+user_id+'/'+page,options);
}

function selectUserInfo(blog_id,theme_id,page){
	var options = {asynchronous:true,
				   evalScripts:true};
	new Ajax.Updater('user_intro','/ajax/select_user_info/'+blog_id+'/'+theme_id+'/'+page,options);
}

function popupUserInfo(user_id){
	url = "/php/blog/blog_profile_"+user_id+".htm";
	//alert(url);
	w = 500;
	h = 500;
	popup(url,w,h,'no','no');
}