
function ShowDiscuss(id)
{
	$.get("/Utility/BlogDiscuss.aspx", { rnd : Math.random(), id : id }, function(result) {
		if(result.length > 0) {
			$("#diz_infos").html(result);
			IconAction();
			Bind();
		}
	});
}

function CreateDiscuss(obj)
{
	var id = $("#idBlog").val();
	var txt = "";
	var cnt = $("#k_count").val();
	for(var i=1; i<=cnt; i++) {
		if($("#cContent" + i).length > 0) {
			var tmg = $("#cContent" + i).val();
			if(tmg.length == 0) {
				txt += "(第" + i + "题:未答!)";
			}
			else {
				txt += "(第" + i + "题:" + $("#cContent" + i).val() + ") ";
			}
			continue;
		}
		if($("#cContent" + i + "_radio").length > 0) {
			var objs = getElementsByName("cContent" + i + "_radio");
			var tmg = "";
			for(var j=0; j<objs.length; j++) {
				if(objs[j].checked) {
					tmg = objs[j].value;
					txt += "(第" + i + "题:" + objs[j].value + ")";
					break;
				}
			}
			if(tmg.length == 0) {
				txt += "(第" + i + "题:未答!)";
			}
			continue;
		}
		if($("#cContent" + i + "_checkbox").length > 0) {
			var objs = getElementsByName("cContent" + i + "_checkbox");
			var tmg = "";
			for(var j=0; j<objs.length; j++) {
				if(objs[j].checked) {
					tmg += objs[j].value + ", ";
				}
			}
			if(tmg.length > 0) {
				txt += "(第" + i + "题:" + tmg + ")";
			}
			else {
				txt += "(第" + i + "题:未答!)";
			}
			continue;
		}
	}

	if(txt.length > 1800) {
		alert("评论太长了！");
		return;
	}

	if(txt.length > 1) {
		$.get("/Utility/DiscussCreate.aspx", { rnd : Math.random(), idBlog : id, cContent : txt }, function(result) {
			ShowDiscuss(id);
			obj.style.display = "none";
		});
	}
}


function CreateDiscussSingle()
{
	var id = $("#idBlog").val();
	var objs = getElementsByName("cContent");
	var txt = "";
	for(var i=0; i<objs.length; i++) txt += objs[i].value + " ";
	if(txt.length > 1800) {
		alert("评论太长了！");
		return;
	}
	if(txt.length > 1) {
		$.get("/Utility/DiscussCreate.aspx", { rnd : Math.random(), idBlog : id, cContent : txt }, function(result) {
			ShowDiscuss(id);
		});
	}
}

function ShowNext(id,user)
{
	$.get("/Utility/BlogNext.aspx", { rnd : Math.random(), id : id, iduser : user }, function(result) {
		if(result.length > 0) {
			$("#blog_next_txt").html(result);
		}
	});
}

function BlogDelete(id,md5)
{
   if (confirm("确定要删除这个文章吗？\nREALY WANT TO DELETE THIS BLOG?") == true) 
   {
      $.get("/Utility/BlogDelete.aspx" , { rnd : Math.random(), id : id, checksum : SingleLine(md5) }, function(result) { 
         if(result == "OK")
         {
             alert("文章已经被删除!\nBLOG DELETED!"); 
			 window.location = "/Computer/BlogList.aspx";
         }
		 else
		 {
			alert(result);
		 }
      });
   }
}


function BlogDelete_Mobile(id,md5)
{
   if (confirm("确定要删除这个文章吗？\nREALY WANT TO DELETE THIS BLOG?") == true) 
   {
      $.get("/Utility/BlogDelete.aspx" , { rnd : Math.random(), id : id, checksum : SingleLine(md5) }, function(result) { 
         if(result == "OK")
         {
             alert("文章已经被删除!\nBLOG DELETED!"); 
			 window.location = "/Mobile/";
         }
		 else
		 {
			alert(result);
		 }
      });
   }
}

function ShowDiz()
{
	if($("#blog_speak_mem").css("display") == "none") { $("#blog_speak_mem").css("display", ""); }
	else { $("#blog_speak_mem").css("display", "none"); }
}
