// JavaScript Document
//在线反馈页面输入检查
function feedback_check(){
	if(!check_name()){
		return false;
	}
	if(!check_email()){
		return false;
	}
	if(!check_title()){
		return false;
	}
	if(!check_content()){
		return false;
	}
	if(!check_vcode()){
		return false;
	}
}

function apply_check(){
	if(!check_name()){
		return false;
	}
	if(!check_age()){
		return false;
	}
	if(!check_stature()){
		return false;
	}
	if(!check_education()){
		return false;
	}
	if(!check_address()){
		return false;
	}
	if(!check_telephone()){
		return false;
	}
	if(!check_email()){
		return false;
	}
	if(!check_experience()){
		return false;
	}
	if(!check_vcode()){
		return false;
	}
}

var icon_path_error = '<img src="../language/zh/default/icon/texterror.png" border="0" align="absmiddle"/>';
var icon_path_error2 = '<img src="../language/zh/default/icon/textright.png" border="0" align="absmiddle"/>';

//姓名
function check_name(){
	var name = $('#name').val();
	var nameLength = name.length;
	if(name == ''){
		$('#error_name').html(icon_path_error + '&nbsp;请输入您的姓名.');
		return false;
	}else{
		if(nameLength > 20){
			$('#error_name').html(icon_path_error + '&nbsp;姓名请不要超过20个字符.');
			return false;
		}
		$('#error_name').html(icon_path_error2);
		return true;
	}
}

//邮箱地址
function check_email(){
	var email = $('#email').val();
	var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,3}$/
	if(email == ''){
		$('#error_email').html(icon_path_error + '&nbsp;请输入您的邮箱地址.');
		return false;
	}else{
		if(!reg.test(email)){
			$('#error_email').html(icon_path_error + '&nbsp;请输入有效的邮箱地址.');
			return false;
		}
		$('#error_email').html(icon_path_error2);
		return true;
	}
}

//标题
function check_title(){
	var title = $('#title').val();
	var titleLen = title.length;
	if(title == ''){
		$('#error_title').html(icon_path_error + '&nbsp;请输入标题.');
		return false;
	}else{
		if(titleLen > 50){
			$('#error_title').html(icon_path_error + '&nbsp;标题请不要超过50个字符.');
			return false;
		}
		$('#error_title').html(icon_path_error2);
		return true;
	}
}

//反馈内容
function check_content(){
	var content = $('#content').val();
	var contentLen = content.length;
	if(content == ''){
		$('#error_content').html(icon_path_error + '&nbsp;请输入留言内容.');
		return false;
	}else{
		if(contentLen > 1000){
			$('#error_content').html(icon_path_error + '&nbsp;留言内容请不要超过1000个字符.');
			return false;
		}
		$('#error_content').html(icon_path_error2);
		return true;
	}
}

//验证码
function check_vcode(){
	var vcode = $('#vcode').val();
	var vcodeLen = vcode.length;
	if(vcode == ''){
		$('#error_vcode').html(icon_path_error + '&nbsp;请输入验证码.');
		return false;
	}else{
		if(vcodeLen < 4){
			$('#error_vcode').html(icon_path_error + '&nbsp;请完整地输入验证码.');
			return false;
		}
		$('#error_vcode').html('*');
		return true;
	}
}

//年龄
function check_age(){
	var age = $('#age').val();
	var reg = /^[0-9]{2}$/;
	if(age == ''){
		$('#error_age').html(icon_path_error + '&nbsp;请输入年龄.');
		return false;
	}else{
		if(!reg.test(age)){
			$('#error_age').html(icon_path_error + '&nbsp;请正确地输入您的年龄.');
			return false;
		}
		$('#error_age').html('*');
		return true;
	}
}

//身高,非必填项
function check_stature(){
	var stature = $('#stature').val();
	var reg = /^[0-9]{3}$/;
	if(stature != ''){
		if(!reg.test(stature)){
			$('#error_stature').html(icon_path_error + '&nbsp;请正确地输入您的身高.');
			return false;
		}else{
			$('#error_stature').html('');
			return true;
		}
	}
}

//毕业学校
function check_education(){
	var education = $('#education').val();
	if(education == ''){
		$('#error_education').html(icon_path_error + '&nbsp;请输入您的毕业学校.');
		return false;
	}else{
		$('#error_education').html('');
		return true;
	}
}

//住址
function check_address(){
	var address = $('#address').val();
	if(address == ''){
		$('#error_address').html(icon_path_error + '&nbsp;请输入您的住址.');
		return false;
	}else{
		$('#error_address').html('');
		return true;
	}
}

//电话号码
function check_telephone(){
	var telephone = $('#telephone').val();
	var reg = /(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}1[35][0-9]{9}$)/;
	if(telephone == ''){
		$('#error_telephone').html(icon_path_error + '&nbsp;请输入您的电话号码.');
		return false;
	}else{
		if(!reg.test(email)){
			$('#error_telephone').html(icon_path_error + '&nbsp;请正确地输入您的电话号码.');
			return false;
		}
		$('#error_telephone').html(icon_path_error2);
		return true;
	}
}

//工作经验
function check_experience(){
	var experience = $('#experience').val();
	var experienceLen = experience.length;
	if(experience == ''){
		$('#error_experience').html(icon_path_error + '&nbsp;请输入您的工作经验和技能特长.');
		return false;
	}else{
		if(experienceLen >= 65536){
			$('#error_experience').html(icon_path_error + '&nbsp;留言内容请不要超过65536个字符.');
			return false;
		}
		$('#error_experience').html(icon_path_error2);
		return true;
	}
}