﻿var author_="您的昵称";
var content_="注：请勿发无意义的建议！";
var submit_=" 发表建议 ";
var submitpost_="正在提交...";
var oco_="全部展开";
var occ_="全部隐藏";
var commentlimit = 500;
var aText={
ok:"您的建议已提交！谢谢！",
repeat:"请不要重复提交!",
namenull:"请填写联系方式!",
nameoverstep:"联系方式不能超过64个字节!",
repeatauthor:"您使用的昵称已被注册，请换一个昵称或登录后再试!",
emptycontent:"请输入建议内容!",
overstep:"建议内容不能小于10个字节或超过 "+commentlimit+" 个字节！",
overtime:"系统限制60秒内只能发表一次建议!",
noexist:"该主题不存在或已被删除!",
close:"建议功能已被管理员暂时关闭!",
badword:"你的建议内容中包含系统限制的内容!",
cerror:"验证码错误,请重新填写!",
error:"暂时无法使用建议功能，请稍后再试!"
};
function xmlHttp(){
	if (document.all){
		for (var i=0; i<2; i++)try{
			var r = new ActiveXObject(["MSXML2.XMLHTTP", "Microsoft.XMLHTTP"][i]);
			return r;
		}catch (e) {
			return null;
		}
	} else return new XMLHttpRequest();
}
function postdata(url, fun, data){
	var xmlHttp = this.xmlHttp();
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.onreadystatechange = function(){if(xmlHttp.readyState==4) fun (xmlHttp);};
	xmlHttp.send('action=add&ajax=1&code='+data[2]+'&author='+escape(data[0])+'&content='+escape(data[1]));
    //alert(xmlHttp.responseText);
}
function cleardisabled(){
	clearTimeout(cldt);
	$('cf_submit').disabled = false;
}
function postnull(r){
$('cf_content').value = "";
$('cf_author').value = "";
}

function reloadVerifyImg(obj) {
	         obj.src = 'ImgCode.aspx?action=image&tmp=' + Math.random();
	     }
	     
function postcmt(r){
	//if($("notice")) $("notice").removeNode(true);
	if(r){
		var result = r.responseText;alert(aText[aText[result]?result:"error"]);
		$('cf_submit').value = submit_;
		cldt=window.setTimeout("cleardisabled()",5000);
		$('cf_author').value = "";
		$('cf_content').value="";
		reloadVerifyImg($('ImgValid'));
		return;
	}
	if($('cf_author').value.length==0)
	{
	  alert(aText['namenull']);
		$('cf_author').focus();
		return false;
	}
	else if(strlen($('cf_author').value)>=64){
		alert(aText['nameoverstep']);
		$('cf_author').focus();
		return false;
	}
	if($('icode').value.length==0)
	{
	  alert('验证码必填');
	  $('icode').foucs();
	  return false;
	}
	if($('cf_content').value.length==0){
		alert(aText['emptycontent']);
		$('cf_content').focus();
		return false;
	} else if(strlen($('cf_content').value)<10 || strlen($('cf_content').value)>commentlimit){
		alert(aText['overstep']);
		$('cf_content').focus();
		return false;
	}
	$('cf_submit').value = submitpost_;
	$('cf_submit').disabled = true;
	var data = [$('cf_author').value, $('cf_content').value,$('icode').value];
	postdata('/postbox.aspx', postcmt, data); 
}

