/**
* o_type:1-话题，2-活动
* gid:圈子ID，
* o_id：话题/活动ID
* page：当前分页号
*/
//加载圈子评论信息
function loadGCommentAdd(o_id){
	var url = '/?m=group&a=page_m_comment_add';	var pars = 'o_id='+o_id;
	new Ajax.Updater('group_comment_add',url,{method: 'post',parameters: pars,evalScripts:true});
}
function loadGCommentList(o_id,page){
	var url = '/?m=group&a=page_g_comment_list'; var pars = 'o_id='+o_id+'&page='+page;
	new Ajax.Updater('group_comment_list',url,{method: 'post',parameters: pars,evalScripts:true});
}
function report(id,type,uid){
	if(uid<=0){alert("您还未登录，暂不能举报：）");return false;}
	var url = '/?m=pc&a=page_c_report_insert_c_report';	var pars = 'targetId=' + id + '&targetType=' + type + '&uid=' + uid;
	var myAjax = new Ajax.Request(url,{method: 'post',parameters: pars,onComplete: showResponse});
}
function showResponse(originalRequest){	alert(originalRequest.responseText);}
//改变验证码
function changeCommentValidecode(obj){
	var stamp = Math.random();
	$(obj).src = '/?m=pc&a=page_f_seccode&rand='+ stamp;
}
function GCommentCheck(){
	if($('c_content').value == ''){
		alert("请输入评论内容！");
		return false;
	}
	if($('c_content').value.length > 300){
		alert("评论内容太长，超过300个字！");
		return false;
	}
	/*if($('valicode').value == ''){
		alert("请输入验证码！");
		return false;
	} + '&valicode=' + valicode*/
	$('CommentSubmit').disabled=true;
	$('CommentSubmiting').style.display = "block";
	var o_id 	= $('o_id').value;
	var quote_id 	= $('quote_id').value;
	var sessid	= $('sessid').value;
	var c_content = encodeURIComponent($('c_content').value);
	//var valicode= $('valicode').value;	
		
	var url = '/?m=group&a=do_g_comment_add';
	var pars = 'sessid=' + sessid + '&o_id=' + o_id + '&c_content=' + c_content + '&quote_id='+ quote_id ;
//new Ajax.Updater('html_comment_submit',url,{method: 'post',parameters: pars,evalScripts:true});
	new Ajax.Request(url,{method: 'post',parameters: pars,evalScripts:true,onComplete: doRequest});
	return false;
}
function doRequest(info){
	var o_id = $('o_id_flag').value;
	if	(info.responseText == 'NOBODY'){
		nobody();	
	} /*else if (info.responseText == 'VALIERRO'){
		valierro();
	}*/ 
	else if (info.responseText == 'TIMESHORT'){
		timeshortout();
	}else{
		var page = parseInt(info.responseText);
		alert('评论成功');
		loadGCommentAdd(o_id);
		loadGCommentList(o_id,page);
		if (page>0){
			$("group_comment_list").scrollIntoView();
		}
	}
}
/*function valierro(){
    alert('验证码错误！');
    $('CommentSubmit').disabled=false;
    $('CommentSubmiting').style.display = 'none';
	changeCommentValidecode('chk_img');
}*/
function nobody(){
    alert('请填内容！');
    $('CommentSubmit').disabled=false;
    $('CommentSubmiting').style.display = 'none';
	changeCommentValidecode('chk_img');
}
function timeshortout(){
	alert('回复太频繁，请稍后再回！');
    $('CommentSubmit').disabled=false;
    $('CommentSubmiting').style.display = 'none';
	changeCommentValidecode('chk_img');
}

