function Trim(s){
  return s.replace(/^\s*|\s*$/gi,"")
}
function isValidEmail(email) {      
  var regex = /^([a-zA-Z0-9_\.\'\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  return regex.test(email);
}

function checkReg(theform){
  if(Trim(theform.name.value)==""){
  	alert("姓名不能为空");
  	return false;
  	}
  if(Trim(theform.company.value)==""){
  	alert("单位不能为空");
  	return false;
  	}	
  if(Trim(theform.contact.value)==""){
  	alert("联系电话不能为空");
  	return false;
  	}	
  if(Trim(theform.email.value)==""){
  	alert("email不能为空");
  	return false;
  	}
  if(Trim(theform.postcode.value)==""){
  	alert("邮编不能为空");
  	return false;
  	}	
  if(Trim(theform.address.value)==""){
  	alert("邮寄地址不能为空");
  	return false;
  	}	
  return true;	
}

function checkRegEn(theform){
  if(Trim(theform.name.value)==""){
  	alert("Please fill in your name!!");
  	return false;
  	}
  if(Trim(theform.company.value)==""){
  	alert("Please fill in your company name!!");
  	return false;
  	}	
  if(Trim(theform.contact.value)==""){
  	alert("Please fill in your phone number!!");
  	return false;
  	}	
  if(Trim(theform.email.value)==""){
  	alert("Please fill in your email!!");
  	return false;
  	}
  if(Trim(theform.postcode.value)==""){
  	alert("Please fill in your postal code!!");
  	return false;
  	}	
  if(Trim(theform.address.value)==""){
  	alert("Please fill in your address!!");
  	return false;
  	}	
  return true;	
}

function checkUpfile(theform){
  if(Trim(theform.name.value)==""){
  	alert("姓名不能为空");
  	return false;
  	}
  if(Trim(theform.contact.value)==""){
  	alert("联系电话不能为空");
  	return false;
  	}	
  if(Trim(theform.email.value)==""){
  	alert("email不能为空");
  	return false;
  	}
  if(Trim(theform.good.value)==""){
  	alert("还没有选择要上传的作品");
  	return false;
  	}
  if(Trim(theform.describe.value)==""){
  	alert("作品说明不能为空");
  	return false;
  	}	
  return true;	
}

function checkUpfileEn(theform){
  if(Trim(theform.name.value)==""){
  	alert("Please fill in your name!!");
  	return false;
  	}
  if(Trim(theform.contact.value)==""){
  	alert("Please fill in your phone number!!");
  	return false;
  	}	
  if(Trim(theform.email.value)==""){
  	alert("Please fill in your email!!");
  	return false;
  	}
  if(Trim(theform.good.value)==""){
  	alert("Please choose the file your want to upload!!");
  	return false;
  	}
  if(Trim(theform.describe.value)==""){
  	alert("Please fill in description of your writing!!");
  	return false;
  	}	
  return true;	
}
