function CharCount() {
	MAX_WORD = 1000;

	var contentString = document.BMForm.comment.value;

	var numOfChars = contentString.match(/\.*/g);

	document.BMForm.showSize.value = (MAX_WORD+1)-numOfChars.length;
	if (numOfChars.length > (MAX_WORD+1)) {
		document.BMForm.comment.value = contentString.substring(0,MAX_WORD);
		window.alert("留言内容被限制在 MAX_WORD 字符!");
	}
	if (numOfChars.length > MAX_WORD) { document.BMForm.showSize.value = 0; }
}


function CheckDate(){
	comment = document.BMForm.comment.value;
	name = document.BMForm.name.value;
	Password = document.BMForm.password.value;
	email = document.BMForm.email.value;
	if (comment=="") {
		alert("请输入留言内容！");
		document.BMForm.comment.focus();
		return false;
	}
	if (comment!=""){
		if(!validate_user_text(comment))
			return false;
	}
	if (name==""){
		alert("请输入昵称！");
		document.BMForm.name.focus();
		return false;
	}
	if (name!=""){
		if(!validate_user_text(name))
			return false;
	}
	
	if (Password==""){
		alert("请输入管理密码！");
		document.BMForm.password.focus();
		return false;
	}
	if (Password!="940718"){
		alert("管理密码错误！");
		document.BMForm.password.focus();
		return false;
	}
	
	
	if (Password="940718"){
		if(!validate_user_text(name))
			return false;
	}
	
	
	
	if (email!=""){
		if (!check_email(document.BMForm.email.value)){
			alert('Email地址错误! 请重新输入或缺省。');
			document.BMForm.email.focus();
			return false;
		}
		if(!validate_user_text(email))
			return false;
	}
	else return true;
}

function check_email(address) {
	if ((address == "")|| (address.indexOf ('@') == -1)|| (address.indexOf ('.') == -1))
		return false;
		return true;
}
function validate_user_text(usertext){
	var swear_words_arr=new Array("|","■");
	var swear_alert_arr=new Array;
	var swear_alert_count=0;

	reset_alert_count();
 	var compare_text=usertext;
	for(var i=0; i<swear_words_arr.length; i++){
		for(var j=0; j<(compare_text.length); j++){
			if(swear_words_arr[i]==compare_text.substring(j,(j+swear_words_arr[i].length)).toLowerCase()){
				swear_alert_arr[swear_alert_count]=compare_text.substring(j,(j+swear_words_arr[i].length));
				swear_alert_count++;
			}
		}
	}
	var alert_text="";
	for(var k=1; k<=swear_alert_count; k++){
		alert_text+="\n" + "(" + k + ")  " + swear_alert_arr[k-1];
	}
	if(swear_alert_count>0){
		alert("含有系统保留字符:" + alert_text );
		//document.BMForm.comment.select();
	}else{
		return true;
	}
}
function reset_alert_count(){
	swear_alert_count=0;
}

window.onload=reset_alert_count;

function clearField(field){
	if (field.value == field.defaultValue) {
		field.value = "";
	}
}
function checkField(field){
	if (field.value == ""){
		field.value = field.defaultValue;
	}
}


var currentpos,timer;
function initialize() {
	timer=setInterval("scrollwindow()",10);
}
function sc() {
	clearInterval(timer);
}
function scrollwindow() {
	currentpos=document.body.scrollTop; window.scroll(0,++currentpos);
	if (currentpos != document.body.scrollTop) sc();
}
document.onmousedown=sc
document.ondblclick=initialize
function New(para_URL) {
	var URL =new String(para_URL)
	window.open(URL,'','resizable,scrollbars')
}

function openwindow(url, width, height){
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0,location=no,directories=no');
}

