


addEvent(window, 'load',
	function(){
	
		// add validation to the form
		var form = document.getElementById('form_contact');
		if (form){
			form.onsubmit = function(){
				
				var aErrors = [];

				if (this.person_name_given.value.trim() == ''){
					aErrors.push('- Given name is required');
				}

				if (this.person_name_family.value.trim() == ''){
					aErrors.push('- Family name is required');
				}

				var sEmail = this.person_email.value.trim();
				if (sEmail == ''){
					aErrors.push('- Email is required');
				} else if (!email_valid(sEmail)){
					aErrors.push('- Email is invalid');
				}
				
				if (aErrors.length > 0){
					var sErrors = '';
					sErrors += 'Please correct the following\n';
					sErrors += aErrors.join('\n');
					alert(sErrors);
					return false;
				} else {
					return true;
				}
			}
		}
	}
);