// JavaScript Document

function checkemail(){

		var str=document.getElementById('contactForm').email.value;
		var msgstr = "Please input a valid email address!"

	var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str) && str != "username@mydomain.com"){
		testresults=true;
	}else{
		alert(msgstr);
		testresults=false;
	}
	return (testresults);
} 
function checkemailRego(){

		var str=document.getElementById('regoForms').gpEmail.value;
		var msgstr = "Please input a valid email address!"

	var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str) && str != "username@mydomain.com"){
		testresults=true;
	}else{
		alert(msgstr);
		testresults=false;
	}
	return (testresults);
} 
function checkemail2(){

		var str=document.getElementById('registrationForm').email.value;
		var msgstr = "Please input a valid email address!"

	var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str) && str != "username@mydomain.com"){
		testresults=true;
	}else{
		alert(msgstr);
		testresults=false;
	}
	return (testresults);
} 
function Validate10(){
	myForm = document.getElementById('contactForm');

	if(myForm.name.value==''){
		alert('Please enter your Name');
		myForm.name.focus();
		return false;
	}
	if (checkemail() == false){
			myForm.email.focus();
			return false;
	}	
	
		return true;	
}

function Validate(){
	myForm = document.getElementById('contactForm');

	if(myForm.name.value==''){
		alert('Please enter your Name');
		myForm.name.focus();
		return false;
	}
	if (checkemail() == false){
			myForm.email.focus();
			return false;
	}
	if(myForm.comments.value==''){
		alert('Please enter a Comment');
		myForm.comments.focus();
		return false;
	}
	
	
		return true;	
}
function validReg(){
	myForm = document.getElementById('registrationForm');

	if(myForm.name.value==''){
		alert('Please enter your Name');
		myForm.name.focus();
		return false;
	}
	if (checkemail2() == false){
			myForm.email.focus();
			return false;
	}
	if(myForm.event.value=='Select'){
		alert('Please choose an Event');
		myForm.event.focus();
		return false;
	}
	if(myForm.numTickets.value==''){
		alert('Please enter the number of tickets');
		myForm.numTickets.focus();
		return false;
	}
	
		return true;	
}

function checkemail3(){

		var str=document.getElementById('newsForm').Email.value;
		var msgstr = "Please input a valid email address!"

	var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str) && str != "username@mydomain.com"){
		testresults=true;
	}else{
		alert(msgstr);
		testresults=false;
	}
	return (testresults);
} 


function validate3(){
	myForm = document.getElementById('newsForm');

	if(myForm.name.value==''){
		alert('Please enter your First Name');
		myForm.name.focus();
		return false;
	}
	if(myForm.last.value==''){
		alert('Please enter Your Last Name');
		myForm.last.focus();
		return false;
	}
	if (checkemail3() == false){
			myForm.Email.focus();
			return false;
	}
	
		return true;	
}

function validateNewRego(){
	myForm = document.getElementById('regoForms');
		if(myForm.gpName.value=='') { alert("Section 1: First Name.");	myForm.gpName.focus(); return false; }
		if(myForm.gpLName.value=='') { alert("Section 1: Last Name."); 	myForm.gpLName.focus();return false; }
		if(checkemailRego() == false) { myForm.gpEmail.focus();return false; }
		if(myForm.gpPhone.value=='') { alert("Section 1: Contact Phone."); 	myForm.gpPhone.focus();return false; }
		if(myForm.gpCountry.value=='') { alert("Section 1: Country."); 	myForm.gpCountry.focus();return false; }
		if(myForm.gpCity.value=='') { alert("Section 1: City."); 	myForm.gpCity.focus();return false; }
		if(myForm.gpArch.value=='') { alert("Section 1: Arch/Diocese."); 	myForm.gpArch.focus();return false; }
		if(myForm.gpRelation.value== 'yes') { 
			if(myForm.gpRelationYes.value== '') {
				alert("Section 1: Existing relationship details"); 
				myForm.gpRelationYes.focus();
				return false;
			}
		}
		if(myForm.piKids.value=='') { alert("Section 2: Approx number of <strong>pilgrims</strong>."); 	myForm.piKids.focus();return false; }
		if(myForm.piLeaders.value=='') { alert("Section 2: Approx number of <strong>leaders</strong>."); 	myForm.piLeaders.focus();return false; }
		if(myForm.piUnder18.value=='') { alert("Section 2: Number of under 18s."); 	myForm.piUnder18.focus();return false; }
		if(myForm.arSmoker.value=='') { alert("Section 3: Anyone have coners about a household with a smoker."); 	myForm.arSmoker.focus();return false; }
		if(myForm.arSmoker.value== 'yes') { 
			if(myForm.arSmokerDetails== '') {
				alert("Section 3: Household smoker details"); 
				myForm.arSmokerDetails.focus();
				return false;
			}
		}
		if(myForm.piKids.value=='') { alert("Section 2: Approx number of <strong>pilgrims</strong>."); 	myForm.piKids.focus();return false; }

		return true;	

}
