// JavaScript Document
function foldexpand(tid)	{
	var replyareaid = 'replyarea' + tid;
	var foldexpandid = 'foldexpand' + tid;
	var tweetareaid = 'tweetarea' + tid;
	if (document.getElementById(replyareaid).style.display == 'block')	{
		document.getElementById(replyareaid).style.display = 'none';
		document.getElementById(foldexpandid).innerHTML = '<a href="#nogo" />展开评论</a>';
		document.getElementById(tweetareaid).style.marginBottom = '25px';
	}
	else	{
		document.getElementById(replyareaid).style.display = 'block';
		document.getElementById(foldexpandid).innerHTML = '<a href="#nogo" />收起评论</a>';
		document.getElementById(tweetareaid).style.marginBottom = '0px';
	}	
}
function showinput(tid)	{
	document.getElementById('avatar' + tid).style.display = 'block';
	document.getElementById('fakeinput' + tid).style.display = 'none';
	document.getElementById('replyinput' + tid).focus();
}
function getReplyTxtNum(tid)	{
	var Total = document.getElementById('replyinput' + tid).value.length;
	document.getElementById('showtxtnum' + tid).innerHTML = Total;
	if (Total > 140)	{
		document.getElementById('replyinput' + tid).value = document.getElementById('replyinput' + tid).value.substring(0,140);
	}
	if (window.event.keyCode == "13")	{
		document.getElementById('addreplybutton' + tid).click();
	}
}
function addNewReply(tid)	{
	var i = Math.floor(Math.random()*1000);
	var rContent = document.getElementById('replyinput' + tid).value;
	var url = "include/reply.inc.php?action=add&tid=" + tid + "&rcontent=" + encodeURIComponent(rContent) + "&rand=" + i;
	if (rContent != '' && tid != '')	{
		document.getElementById('addreplybutton' + tid).disabled = true;
		document.getElementById('addreplybutton' + tid).value = '请稍候……';
		
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function()	{
		if (xmlhttp.readyState==4)	{
			document.getElementById('addreplybutton' + tid).disabled = false;
			document.getElementById('addreplybutton' + tid).value = '提交';
			document.getElementById('replyinput' + tid).value = '';
			document.getElementById('replylist' + tid).style.display = 'block';
			document.getElementById('replylist' + tid).innerHTML = xmlhttp.responseText;
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		}
	}
	xmlhttp.send(null);
  }
}
function getallreplies(tid)	{
	var i = Math.floor(Math.random()*1000);
	var url = "include/reply.inc.php?action=getall&tid=" + tid + "&rand=" + i;
	if (tid != '')	{
		document.getElementById('getallreplies' + tid).innerHTML = '请稍候……';
		
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function()	{
		if (xmlhttp.readyState==4)	{
			document.getElementById('replylist' + tid).innerHTML = xmlhttp.responseText;
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		}
	}
	xmlhttp.send(null);
  }
}
function getMoreTweet(cid)	{
	var i = Math.floor(Math.random()*1000);
	var lasttid = document.getElementById('thistid').value;
	var currentnum = document.getElementById('thisnum').value;
	var url = "tweetlist.inc.php?action=getmoretweet&cid=" + cid + "&lasttid=" + lasttid + "&currentnum=" + currentnum + "&rand=" + i;
	document.getElementById('getmoretweetext').innerHTML = '请稍候……';
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function()	{
		if (xmlhttp.readyState==4)	{
			document.getElementById('getmore' + lasttid).innerHTML = '';
			document.getElementById('postarea').innerHTML = document.getElementById('postarea').innerHTML + xmlhttp.responseText;
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		}
	}
	xmlhttp.send(null);
}
function getSearchTweet()	{
	var i = Math.floor(Math.random()*1000);
	var lasttid = document.getElementById('thistid').value;
	var currentnum = document.getElementById('thisnum').value;
	var topic = document.getElementById('topicname').value;
	var url = "tweetlist.inc.php?action=getsearchtweet&topic=" + encodeURIComponent(topic) + "&lasttid=" + lasttid + "&currentnum=" + currentnum + "&rand=" + i;
	document.getElementById('getmoretweetext').innerHTML = '请稍候……';
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function()	{
		if (xmlhttp.readyState==4)	{
			document.getElementById('getmore' + lasttid).innerHTML = '';
			document.getElementById('postarea').innerHTML = document.getElementById('postarea').innerHTML + xmlhttp.responseText;
			tb_init('a.thickbox, area.thickbox, input.thickbox');
		}
	}
	xmlhttp.send(null);
}