//You should create the validator only after the definition of the HTML form
var frmvalidator  = new Validator("form3");
frmvalidator.addValidation("firstname","req","Please fill out the First Name field.");
//frmvalidator.addValidation("firstname","maxlen=20",	"Max length for FirstName is 20");
frmvalidator.addValidation("firstname","alpha_s","First name must be alphabetic chars only");


frmvalidator.addValidation("lastname","req","Please fill out the Last Name field.");
frmvalidator.addValidation("lastname","alpha_s","Last name must be alphabetic chars only");

frmvalidator.addValidation("citizenship","req","Please fill out the Citizenship field.");
frmvalidator.addValidation("citizenship","alpha","Last name must be alphabetic chars only");

frmvalidator.addValidation("street","req","Please fill out the Street address field.");

frmvalidator.addValidation("city","req","Please fill out the City field.");
frmvalidator.addValidation("city","alpha_s","City name must be alphabetic chars only");

frmvalidator.addValidation("state","req","Please fill out the State field.");
frmvalidator.addValidation("state","alpha_s","State name must be alphabetic chars only");

frmvalidator.addValidation("country","req","Please choose your Country.");

frmvalidator.addValidation("postal","req","Please fill out the Zip code field.");
frmvalidator.addValidation("postal","numeric","Zip code must be numbers only");

frmvalidator.addValidation("email","req","Please enter your email");
frmvalidator.addValidation("email","email","Invalid email address.");

frmvalidator.addValidation("phone_number-0","req","Please fill out the phone number field correctly.");
frmvalidator.addValidation("phone_number-0","numeric","Phone number must be numeric");
frmvalidator.addValidation("phone_number-1","req","Please fill out the phone number field correctly.");
frmvalidator.addValidation("phone_number-1","numeric","Phone number must be numeric");
frmvalidator.addValidation("phone_number-2","req","Please fill out the phone number field correctly.");
frmvalidator.addValidation("phone_number-2","numeric","Phone number must be numeric");

frmvalidator.addValidation("birthdate-0","req","Please fill out the date of birth correctly.");
frmvalidator.addValidation("birthdate-0","numeric","Month of birth date values must be (1-12)");
frmvalidator.addValidation("birthdate-0","gt=0", "Month of birth date values must be (1-12)");
frmvalidator.addValidation("birthdate-0","lt=13", "Month of birth date values must be (1-12)");

frmvalidator.addValidation("birthdate-1","req","Please fill out the date of birth correctly.");
frmvalidator.addValidation("birthdate-1","numeric","Day of birth date values must be (1-31)");
frmvalidator.addValidation("birthdate-1","gt=0", "Day of birth date values must be (1-31)");
frmvalidator.addValidation("birthdate-1","lt=31", "Day of birth date values must be (1-31)");

frmvalidator.addValidation("birthdate-2","req","Please fill out the date of birth correctly.");
frmvalidator.addValidation("birthdate-2","numeric","Invalid year of birth date. Sample value(1984)");
frmvalidator.addValidation("birthdate-2","gt=1960", "Invalid year of birth date. Sample value(1984)");
frmvalidator.addValidation("birthdate-2","lt=2010", "Invalid year of birth date. Sample value(1984)");

frmvalidator.addValidation("projects","req", "Please enter the name of projects you are applying for.");
frmvalidator.addValidation("project_dates","req", "Please enter the project dates.");

frmvalidator.addValidation("background","req", "Please select one option on background.");

frmvalidator.addValidation("institution","req", "Please fill out the institution name.");
frmvalidator.addValidation("institution","alpha_s","Institution name must be alphabetic chars only");

frmvalidator.addValidation("year_attended","req","Please fill out the Years attended field.");
frmvalidator.addValidation("year_attended","regexp=^[0-9]{1,4}-[0-9]{1,4}$", "Invalid entry on Years attended field. Sample value(1984-1985)");

frmvalidator.addValidation("degrees","req", "Please fill out the degrees earned.");
frmvalidator.addValidation("degrees","alpha_s","Degrees earned must be alphabetic chars only");


frmvalidator.addValidation("academic_concentration","req", "Please fill out the Areas of Academic Concentration.");
frmvalidator.addValidation("academic_concentration","alpha_s","Areas of Academic Concentration must be alphabetic chars only");

frmvalidator.addValidation("oral_proficiency","req", "Please select one option on Level of Oral Proficiency.");
frmvalidator.addValidation("written_proficiency","req", "Please select one option on Level of Written Proficiency.");


frmvalidator.addValidation("skills","req", "Please fill out the interests and skills short question.");
//frmvalidator.addValidation("skills","alpha_s","Interest and skills must be alphabetic chars only");

frmvalidator.addValidation("agree","shouldselchk=on", "You have to agree to the EcuaExperiencia terms and conditions.");
frmvalidator.addValidation("pay","req", "Please select one option on application fee.");


frmvalidator.setAddnlValidationFunction("validateRegionOfInterest"); 

function validateRegionOfInterest()
{	
	if(!document.error_disp_handler.hasError){
		var frm = document.forms["form3"];
		if(false == checkRegionOfInterest())
		{
			sfm_show_error_msg('Please select at least one Region of Interest!', document.getElementById('Field22'));
			return false;
		}
		return true;
	}
	return true;
	
	
}
function checkRegionOfInterest(){
	if(document.getElementById('Field22').checked || document.getElementById('Field23').checked
		|| document.getElementById('Field24').checked || document.getElementById('Field25').checked || document.getElementById('Field26').checked){
		return true;
	}
	return false;
}
