
$(document).ready(function() {
						   	
	$("#ajaxstart").ajaxStart(function(){ 	 	
 	 	$("#ajaxstart").animate({opacity: 'show'}, 'slow');		
		
	});


	$('#add_show').toggle(function(){
 		 $(this).html("以后再说吧");
		 $("#showinputforum").animate({
  				height: 250, opacity: 'show'
			}, 'slow');
	},function(){
  		$(this).html("新留言");
		$("#showinputforum").animate({
			opacity: 'hide'
			}, 'slow');
	});


});



function SubmitForum(){
	
	if($("#forumname").val()=="" || $("#forumtitle").val()=="" || $("#froumcontent").val()=="")
	{
		$("#allertidtext").html('呢称 / 标题 / 内容 不能为空!');
		$("#allertid").animate({opacity: 'show'}, 'slow');	
		window.setTimeout("hideshow('allertid')",10000);
	}else{
			$.post("/forum.php",
				{m:"submitforum", forumname: $("#forumname").val(), forumtitle: $("#forumtitle").val(), froumcontent: $("#froumcontent").val()},
				function(data){
					data = Trim(data);
					if(data == "ok"){
						$("#ajaxstart").animate({opacity: 'hide'}, 'slow');
						$("#allertidtext").html('发表成功，正在转入列表页面...');
						$("#allertid").animate({opacity: 'show'}, 'slow');
						window.location.reload();

					}else{
						$("#ajaxstart").animate({opacity: 'hide'}, 'slow');
						$("#allertidtext").html(data);
						$("#allertid").animate({opacity: 'show'}, 'slow');
					}
				}			
			);
	}
}


function SubmitReply(pid){
	
	if($("#replycontent").val()=="" || $("#replyname").val()=="")
	{
		$("#allertidtext").html('呢称 / 内容 不能为空!');
		$("#allertid").animate({opacity: 'show'}, 'slow');	
		window.setTimeout("hideshow('allertid')",10000);
	}else{
			$.post("/forum.php",
				{m:"submitreply", pid:pid, replycontent: $("#replycontent").val(), replyname: $("#replyname").val()},
				function(data){
					data = Trim(data);
					if(data == "ok"){
						$("#ajaxstart").animate({opacity: 'hide'}, 'slow');
						$("#allertidtext").html('发表成功，正在转入列表页面...');
						$("#allertid").animate({opacity: 'show'}, 'slow');

						window.location.reload();

					}else{
						$("#ajaxstart").animate({opacity: 'hide'}, 'slow');
						$("#allertidtext").html(data);
						$("#allertid").animate({opacity: 'show'}, 'slow');
					}
				}			
			);
	}
}


function jumpurl(tourl)
{
	window.location.href = tourl;
}

function hideshow(divid)
{
	$("#"+divid).animate({opacity: 'hide'}, 'slow');
}

function Trim(str)
{ 
	return str.replace(/^\s*|\s*$/g,""); 
}

