function gotoAnchor(){
	document.location.href="#addcommentAnchor";
	document.getElementById("content_addroot").focus();
}

function showReplyBox(id, isShow){
	var div = document.getElementById("reply_" + id);
	if(isShow){
		var textArea = document.getElementById("content_" + id);
		textArea.value = "";
		div.style.display = "block";
		textArea.focus();			
	}else{
		div.style.display = "none";
	}
}

function blockUser(elem, userId){
	
	elem.outerHTML = "阻止该用户";
	var af = new actform();
	af.setAtn('commentdetail.blockuser');
	af.setUserId(userId);
	af.act();
}

function deleteComment(id){

	var af = new actform();
	af.setAtn('commentdetail.delete');
	af.setReplyId(id);
	af.act();		
}

function addComment(id){
	
	document.getElementById("button_" + id).innerHTML = 
		"<input type='button' value='处理中' disabled />";	
	
	var topicId = document.getElementsByName("commentId")[0].value;	
	var parentId = id == "addroot" ? topicId : $("#parentid_" + id).val();
	var content = $("#content_" + id).val();	
	
	var af = new actform();
	af.setAtn('commentdetail.add');
	af.setParentId(parentId);
	af.setContent(content);
	af.act();		
}

function actform(){
	
	var _form = document.getElementById("actform");
	
	var _atn = document.getElementsByName("atntype")[0];
	var _userId = document.getElementsByName("userId")[0];
	var _replyId = document.getElementsByName("replyId")[0];
	var _parentId = document.getElementsByName("parentId")[0];
	var _content = document.getElementsByName("mycont")[0];
	
	_atn.value = '';
	_userId.value = '';
	_replyId.value = '';
	_parentId.value = '';
	_content.value = '';
		
	this.setAtn = function(atn){
		_atn.value = atn;
	}
	this.setUserId = function(id){
		_userId.value = id;
	}
	this.setReplyId = function(id){
		_replyId.value = id;
	}
	this.setParentId = function(id){
		_parentId.value = id;
	}
	this.setContent = function(con){
		_content.value = con;
	}
	
	this.act = function(){
		_form.submit();
	}
	
	this.debug = function(){
		alert("_atn = " + document.getElementsByName("atntype")[0].value);
		alert("_userId = " + document.getElementsByName("userId")[0].value);
		alert("_replyId = " + document.getElementsByName("replyId")[0].value);
		alert("_parentId = " + document.getElementsByName("parentId")[0].value);
		alert("_content = " + document.getElementsByName("mycont")[0].value);
	}
}

function plshowpanel( vid,type ) { //type 1 show more  0 show less 
		if(type==1)	{
			$('#plless_'+vid).hide();
			$('#plMorevidDescy_'+vid).hide();
			$('#plmore_'+vid).show();
			$('#plLessidDescy_'+vid).show();
		} else {
			$('#plless_'+vid).show();
			$('#plMorevidDescy_'+vid).show();
			$('#plmore_'+vid).hide();
			$('#plLessidDescy_'+vid).hide();
		}
}

function AddText(id, str){
	var ubb = document.getElementById(id);
	if(!ubb){
		ubb = document.getElementsByName(id)[0];
	}  
	var ubbLength = ubb.value.length; 
	ubb.focus(); 
	if(typeof document.selection != "undefined"){ 
		document.selection.createRange().text=str; 
	}else{ 
		ubb.value = ubb.value.substr(0, ubb.selectionStart) + str + ubb.value.substring(ubb.selectionStart, ubbLength); 
	} 
}