// JavaScript Document

function isEmailAddr (s){ 
	var rv = false
	if ((s == null) || (s.length == 0)) 
       rv = false;
  else {
		var reEmail =/([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		//reEmail = /.+\@.+\..+$/
		
		rv = reEmail.test(s)
    }
	if(rv){
	return rv
	}else{
		return false
	}
}
 
 function validation(theForm){
  if (theForm.name.value == ""){
    alert("Please enter your name.");
    theForm.name.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.email_from.value)){
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email_from.focus();
    return (false);
  }
return true
}

function validationVacancy(theForm){
	if (theForm.full_name.value == ""){
		alert("Please enter your full name.");
		theForm.full_name.focus();
		return (false);
  	}
  	if (!isEmailAddr(theForm.email_from.value)){
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		theForm.email_from.focus();
		return (false);
  	}
  
  	if (theForm.phone.value == ""){
		alert("Please enter your contact phone.");
		theForm.phone.focus();
		return (false);
  	}
  
  	if (theForm.attach_cv.value == ""){
		alert("Please upload your CV.");
		theForm.attach_cv.focus();
		return (false);
  	}
	
	if (!theForm.allowed_to_work_in_NZ.checked){
		alert("Please check box if you are legally allowed to work in New Zealand.");
		theForm.allowed_to_work_in_NZ.focus();
		return (false);
  	}
	
	return true;
}
