// JavaScript Document

//check from for book.asp message



function checkBook(){
//alert(document.getElementById("C_name").value)
C_name = document.getElementById("C_name");
RE_name = document.getElementById("re_name");
C_phone = document.getElementById("C_phone");
RE_phone = document.getElementById("re_phone");
C_mail = document.getElementById("C_mail");
RE_mail = document.getElementById("re_mail");
content = document.getElementById("content");
RE_content = document.getElementById("re_content");
if(trimAll(C_name.value)){
	C_name.focus();
	C_name.select();
	RE_name.innerHTML="用户名不能为空,请校验";
	return false;
}

if(trimAll(C_phone.value))
{
	C_phone.focus();
	C_phone.select();
	RE_phone.innerHTML="联系不能为空,请校验";
	return false;
}
else{
	if(!C_phone.value.match(/^(((13[0-9]{1})|159|158|188|189|150|151|152)+\d{8})$/) && !C_phone.value.match(/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/))
	{C_phone.focus();C_phone.select();RE_phone.innerHTML="联系不能为空,请校验";return false;}
}

if(trimAll(C_mail.value)){C_mail.focus();C_mail.select();RE_mail.innerHTML="邮箱不合法,请校验"; return false;}else{
	if(!C_mail.value.match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/))
	{C_mail.focus();C_mail.select();RE_mail.innerHTML="邮箱不合法,请校验"; return false;}
	}
if(trimAll(content.value)){content.focus();content.select();RE_content.innerHTML="留言内容不能为空,请校验";  return false;}
}
//end the method checkBook

function trimAll(str){
	//var str = document.getElementById("username").value;
	var newstr="";
	//alert(str)
	if (str.length > 0){
		for(var i = 0; i < str.length ; i++){
			if(str.charAt(i)=="　" || str.charAt(i)==" ")
				newstr += ""
			else
				newstr += str.charAt(i)
		}
		if(newstr.length<=0){return true;}
	}
	else{return true;}
}