﻿// JavaScript Document

function delreply(num)
{
	$.ajax({
	   type : "POST",
	   url : "/Lcommon/getAjaxDate.asp",
	   async: false,
	   dataType : "html",
	   data : {"Action":"delURemark",
	   "CreatedTime":escape($("div[name='replyBox" + num + "'] div.rptime").text()),
	   "delUUID":escape($("div[name='replyBox" + num + "'] div[name='delUUID']").text())
	  },
	  success : function(msg){
		  $("div[name='replyBox" + num + "']").fadeOut("slow");
		  $("div[name='reline" + num + "']").fadeOut("slow");
		  showTips("true","留言删除成功.");
		  },
	  error : function(){
		  showTips("false","操作失败，请刷新后测试");
	  }
	  });
}

function ureply(num,uuid)
{
	$("#replyContentList div.topreply.replySPForm").replaceWith("");
	$("div[name='replyBox" + num + "']").after($("#cloneReplyForm").html());
	$("#UUID").text(uuid);
}

function ajaxSendUreply(uuid)
{	
	$("#mainReply span.qqh").text("");
	if(getStrLen($("textarea[name='Content']").val()) <= 5)
	{
		$("#mainReply span.qqh").text("多说点吧");
		$("#mainReply span.qqh").fadeIn("slow");
		return;
	}
	$("#mainReply").addClass("hidden1");
	$.ajax({
	   type : "POST",
	   url : "/Lcommon/getAjaxDate.asp",
	   async: false,
	   dataType : "html",
	   data : {"Action":"ajaxGetNow"
	  },
	  success : function(msg){
		  $("#cloneReply div.rptime").text(msg);
		  $("#cloneReply div.replyBox").attr("name","replyBox" + $("#orderNumi").text());
		  $("#cloneReply div.reline").attr("name","reline" + $("#orderNumi").text());
		  $("#cloneReply p.replyp").text($("textarea[name='Content']").val());
		  sendAndShowReply(uuid);
		  },
	  error : function(){
		  showTips("false","操作失败，请刷新后测试");
	  }
	  })
}

function ajaxSendUreply2(obj)
{
	$("#replyContentList span.qqh").text("");
	if(getStrLen($("textarea[name='Content2']").val()) <= 5)
	{
		$("#replyContentList span.qqh").text("多说点吧");
		$("#replyContentList span.qqh").show();
		return;
	}
	$.ajax({
	   type : "POST",
	   url : "/Lcommon/getAjaxDate.asp",
	   async: false,
	   dataType : "html",
	   data : {"Action":"ajaxGetNow"
	  },
	  success : function(msg){
		  $("#cloneReply div.rptime").text(msg);
		  $("#cloneReply div.replyBox").attr("name","replyBox" + $("#orderNumi").text());
		  $("#cloneReply div.reline").attr("name","reline" + $("#orderNumi").text());
		  $("#cloneReply p.replyp").text($("textarea[name='Content2']").val());
		  sendAndShowReply2(obj);
		  },
	  error : function(){
		  showTips("false","操作失败，请刷新后测试");
	  }
	  });
	
}

function sendAndShowReply2(obj)
{
	isSecret = 0;
	if($("#replyContentList :checkbox[name:'secret2']").attr("checked") == true)
	{
		isSecret = 1;
	}
	$("#replyContentList").prepend($("#cloneReply").html());
	$("#replyContentList a.deletelink:first").unbind("click");
	var i = $("#orderNumi").text()
	$("#replyContentList a.deletelink:first").bind("click",function(){
													   delreply(i);
													   });
	$("#orderNumi").text(parseInt($("#orderNumi").text()) + 1);
	$.ajax({
	   type : "POST",
	   url : "/Lcommon/getAjaxDate.asp",
	   async: false,
	   dataType : "html",
	   data : {"Content":escape($("textarea[name='Content2']").val()),
	   "CreatedTime":escape($("#cloneReply div.rptime").text()),
	   "ToUID":escape($("#UUID").text()),
	   "IsSecret":escape(isSecret),
	   "IsReply":escape("1"),
	   "Action":"ajaxURemark"
	  },
	  success : function(msg){
		  showTips("true","留言成功.");
		  },
	  error : function(){
		  showTips("false","操作失败，请刷新后测试");
	  }
	  });
	cancelReply(obj);
	$("fieldset.replytexearea").focus();
}

function sendAndShowReply(uuid)
{
	isSecret = 0;
	if($(":checkbox[name:'secret']").attr("checked") == true)
	{
		isSecret = 1;
	}
	$("#replyContentList").prepend($("#cloneReply").html());
	$("#replyContentList a.deletelink:first").unbind("click");
	var i = $("#orderNumi").text()
	$("#replyContentList a.deletelink:first").bind("click",function(){
													   delreply(i);
													   });
	$("#orderNumi").text(parseInt($("#orderNumi").text()) + 1);
	$.ajax({
	   type : "POST",
	   url : "/Lcommon/getAjaxDate.asp",
	   async: false,
	   dataType : "html",
	   data : {"Content":escape($("textarea[name='Content']").val()),
	   "CreatedTime":escape($("#cloneReply div.rptime").text()),
	   "ToUID":escape(uuid),
	   "IsSecret":escape(isSecret),
	   "IsReply":escape("0"),
	   "Action":"ajaxURemark"
	  },
	  success : function(msg){
		  },
	  error : function(){
		  showTips("false","操作失败，请刷新后测试");
	  }
	  });
	$("#mainReply textarea[name='Content']").val("");
}

function cancelReply(obj)
{
	$(obj).parent().parent().replaceWith("");
	$("#cloneReply span.qqh").hide();
}

function SendShortMessage(ID)
{
	$("#commonAjaxID").attr("value",ID);
	showCommonBg();
	showCommonSendShortMessage();
}

function ShowAddFriend()
{
	showCommonBg();
	//showCommonAddFriend();
	ajaxCommonAddFriend();
}