// JavaScript Document


function doValidation()
{
	var lastName,firstName,email,subject,comments;
	firstName=document.getElementById("firstName").value;
	middleName=document.getElementById("middleName").value;
	lastName=document.getElementById("lastName").value;
	age=document.getElementById("age").value;
	gender=document.getElementById("gender").value;
	occupation=document.getElementById("occupation").value;
	citizenship=document.getElementById("citizenship").value;
	streetAddress=document.getElementById("streetAddress").value;
	cityProvince=document.getElementById("cityProvince").value;
	postalCode=document.getElementById("postalCode").value;
	contactNumber=document.getElementById("contactNumber").value;
	email=document.getElementById("email").value;
	childName=document.getElementById("childName").value;
	childAge=document.getElementById("childAge").value;
	childGender=document.getElementById("childGender").value;
	childCitizenship=document.getElementById("childCitizenship").value;
	subject=document.getElementById("subject").value;
	comments=document.getElementById("comments").value;
	captcha_input=document.getElementById("captcha_input").value;
	
	emailVal = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	
	if(firstName=="")
	{
		alert("First Name field is blank.");
		document.getElementById("firstName").focus();
	}
	
	else if(middleName=="")
	{
		alert("Middle Name field is blank.");
		document.getElementById("middleName").focus();
	}
	else if(lastName=="")
	{
		alert("Last Name field is blank.");
		document.getElementById("lastName").focus();	
	}
	else if(age=="")
	{
		alert("Age field is blank.");
		document.getElementById("age").focus();	
	}
	else if(gender=="")
	{
		alert("Please select your gender");
		document.getElementById("gender").focus();	
	}
	else if(occupation=="")
	{
		alert("Occupation field is blank.");
		document.getElementById("occupation").focus();	
	}
	else if(citizenship=="")
	{
		alert("Citizenship field is blank.");
		document.getElementById("citizenship").focus();	
	}
	else if(streetAddress=="")
	{
		alert("Street Address field is blank.");
		document.getElementById("streetAddress").focus();	
	}
	else if(cityProvince=="")
	{
		alert("City and Province field is blank.");
		document.getElementById("cityProvince").focus();	
	}
	else if(postalCode=="")
	{
		alert("Postal Code field is blank.");
		document.getElementById("postalCode").focus();	
	}
	else if(contactNumber=="")
	{
		alert("Contact Number field is blank.");
		document.getElementById("contactNumber").focus();	
	}
	else if(email=="")
	{
		alert("Email Address field is blank.");
		document.getElementById("email").focus();
	}
	else if(!emailVal.test(email))
	{
		alert("Email Address is not a valid format.");
		document.getElementById("email").focus();
	}
	else if(childName=="")
	{
		alert("Name of Child field is blank.");
		document.getElementById("childName").focus();
	}
	else if(childAge=="")
	{
		alert("Age of Child field is blank.");
		document.getElementById("childName").focus();
	}
	else if(childGender==""){
		alert("Please select your child's gender");
		document.getElementById("childGender").focus();
	}
	else if(childCitizenship=="")
	{
		alert("Child Citizenship field is blank.");
		document.getElementById("childCitizenship").focus();
	}
	else if(subject=="")
	{
		alert("Subject field is blank.");
		document.getElementById("subject").focus();
	}
	else if(comments=="")
	{
		alert("You haven't input any kind of message in the text area");
		document.getElementById("comments").focus();
	}
	else if(captcha_input=="")
	{
		alert("Please type the code shown by entering this code you help us prevent spam and fake registrations. This code is case-sensitive.");
		document.getElementById("captcha_input").focus();
	}
	else
	{	alert("Please wait...");
		document.captchaForm.submit();
	}
}

function resetta()
{
	var obj=document.getElementById('captchaForm');
	var n=obj.elements.length;
	for(var i=0;i<n;i++){if(obj.elements[i].type == "text" || obj.elements[i].type == 'textarea'){obj.elements[i].value = ''}};
	return false;
}

