function isEmptyString(str){

	var reg = /^[\s]*$/;
	if(str.match(reg)){
		return true;
	}
	else{
		return false;
	}
}

function isValidateUserName(str){

	var reg = /^[^ '<>\f\n\r\t\n]{1,}$/;
	if(str.match(reg)){
		return true;
	}
	else{
		return false;
	}
}

function isValidateEmail(str){

	var reg = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if(str.match(reg)){
		return true;
	}
	else{
		return false;
	}
}

function isValidateString(str){

	var reg = /^[^<>]{0,}$/;
	if(str.match(reg)){
		return true;
	}
	else{
		return false;
	}
}

function isValidateYear(str){

	var reg = /^[\d]{2}$/;
	if(str.match(reg)){
		return true;
	}
	else{
		return false;
	}
}

function isValidateTel(str){
	var reg = /^([0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9|\s]{3,15}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9})$/;
	if(reg.test(str)){
		return true;
	}
	else{
		return false;
	}
}

function validateForgetPwd(){
	if(isEmptyString(document.all.uidoremail.value)){
		alert("请输入用户名或者电子邮件地址");
		return false;
	}
	else{
		return true;
	}
}

function validateChangeEmail(){
	if(!isValidateEmail(document.all.oldemail.value)){
		alert("请输入您的旧Email地址");
		return false;
	}
	if(!isValidateEmail(document.all.newemail.value)){
		alert("请输入您的新Email地址");
		return false;
	}
	
	return true;
}

function validateRegister(){
	if(!isValidateUserName(document.all.uid.value)){
		alert("请输入用户名");
		return false;
	}
	if(!isValidateEmail(document.all.email.value)){
		alert("请输入电子邮件地址");
		return false;
	}
	if(!isValidateString(document.all.firstname.value)){
		alert("请检查您输入的姓，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}
	if(!isValidateString(document.all.lastname.value)){
		alert("请检查您输入的名，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}
	if(!isValidateYear(document.all.year.value)&&document.all.year.value!=""){
		alert("请检查您输入的出生日期，您应该在输入框填写两位数字。例如：如果您是1970出生则输入70");
		return false;
	}
	if(!isValidateTel(document.all.phone.value)&&document.all.phone.value!=""){
		alert("请检查您输入的电话。 您只可以输入数字或者横线(-)");
		return false;
	}
	if(!isValidateString(document.all.address.value)){
		alert("请检查您输入的地址，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}
	if(!isValidateString(document.all.salary.value)){
		alert("请检查您输入的月薪，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}

	return true;
}

function validatePersonal(){

	if(!isValidateString(document.all.firstname.value)){
		alert("请检查您输入的姓，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}
	if(!isValidateString(document.all.lastname.value)){
		alert("请检查您输入的名，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}
	if(!isValidateYear(document.all.year.value)&&document.all.year.value!=""){
		alert("请检查您输入的出生日期，您应该在输入框填写两位数字。例如：如果您是1970出生则输入70");
		return false;
	}
	if(!isValidateTel(document.all.phone.value)&&document.all.phone.value!=""){
		alert("请检查您输入的电话。 您只可以输入数字或者横线(-)");
		return false;
	}
	if(!isValidateString(document.all.address.value)){
		alert("请检查您输入的地址，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}

	return true;
}

function isValidateSame(str1,str2){
	if(str1!=str2){
		return false;
	}
	return true;
}

function validateRegistration(){

	if(!isValidateSame(document.all.pwd1.value,document.all.pwd2.value)){
		alert("您所输入密码不匹配，请重新输入");
		return false;
	}

	if(!isValidateEmail(document.all.email.value)){
		alert("请输入电子邮件地址");
		return false;
	}
	return true;
}

function validateLogin(){
	if(!isValidateUserName(document.all.uid.value)){
		alert("请输入用户名，其中不应该包含 \"<\" 或者 \">\"");
		return false;
	}
	/*if(isEmptyString(document.all.pwd.value)){
		alert("请输入密码");
		return false;
	}*/
}

function openSCORoot(item_id) 
{
	var handle = window.open("scoroot.asp?item_id=" + item_id,"SCORoot","height=510,width=775,left=" + (screen.width-775)/2 + ",top="+(screen.height-510)/2+",toolbar=no");
	handle.focus();
}