function validateForm(theForm, emailStr)
{
	if (theForm.frmForename.value == "")
	{
	alert("RUN ARMAGH: Please enter your forename");
	theForm.frmForename.focus();
	result = false;
	return result;
	}

	if (theForm.frmSurname.value == "")
	{
	alert("RUN ARMAGH: Please enter your surname");
	theForm.frmSurname.focus();
	result = false;
	return result;
	}

	if (theForm.frmEmail.value == "")
	{
	alert("RUN ARMAGH: Please enter your email address");
	theForm.frmEmail.focus();
	result = false;
	return result;
	}

	if (!theForm.frmEmail.value == theForm.frmEmail2.value)
	{
	alert("RUN ARMAGH: Your email addresses do not match");
	theForm.frmEmail2.focus();
	result = false;
	return result;
	}

///////////////////////////////////////////////////////////////////////////
//	EMAIL VALIDATION
///////////////////////////////////////////////////////////////////////////

var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null)
{
alert("RUN ARMAGH: Your email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++)
{
	if (user.charCodeAt(i)>127)
	{
	alert("RUN ARMAGH: Your username contains invalid characters");
	return false;
   }
}

for (i=0; i<domain.length; i++)
{
	if (domain.charCodeAt(i)>127)
	{
	alert("RUN ARMAGH: Your domain name contains invalid characters");
	return false;
   }
}

if (user.match(userPat)==null)
{
alert("RUN ARMAGH: Your username doesn't seem to be valid");
return false;
}

var IPArray=domain.match(ipDomainPat);

if (IPArray!=null)
{
	for (var i=1;i<=4;i++)
	{
		if (IPArray[i]>255)
		{
		alert("RUN ARMAGH: Your destination IP address is invalid");
		return false;
   }
}
return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;

for (i=0;i<len;i++)
{
	if (domArr[i].search(atomPat)==-1)
	{
	alert("RUN ARMAGH: Your domain name doesn't seem to be valid");
	return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
{
alert("RUN ARMAGH: Your address must end in a well-known domain or two letter " + "country");
return false;
}

if (len<2)
{
alert("RUN ARMAGH: Your address is missing a hostname");
return false;
}

///////////////////////////////////////////////////////////////////////////
//	EMAIL VALIDATION - END
///////////////////////////////////////////////////////////////////////////

	if (theForm.frmAge.value == "xxx")
	{
	alert("RUN ARMAGH: Please select your age on race day");
	theForm.frmAge.focus();
	result = false;
	return result;
	}

	if (theForm.frmDOB.value == "")
	{
	alert("RUN ARMAGH: Please enter your date of birth");
	theForm.frmDOB.focus();
	result = false;
	return result;
	}

	if (theForm.frmAddress1.value == "")
	{
	alert("RUN ARMAGH: Please enter the first line of your address");
	theForm.frmAddress1.focus();
	result = false;
	return result;
	}

	if (theForm.frmAddress3.value == "")
	{
	alert("RUN ARMAGH: Please enter your town/city");
	theForm.frmAddress3.focus();
	result = false;
	return result;
	}

	if (theForm.frmAddress4.value == "")
	{
	alert("RUN ARMAGH: Please enter your county");
	theForm.frmAddress4.focus();
	result = false;
	return result;
	}

	if (theForm.frmPostcode.value == "")
	{
	alert("RUN ARMAGH: Please enter your postcode");
	theForm.frmPostcode.focus();
	result = false;
	return result;
	}

	if (theForm.frmContactNumber.value == "")
	{
	alert("RUN ARMAGH: Please enter your contact number");
	theForm.frmContactNumber.focus();
	result = false;
	return result;
	}

	if (theForm.frmEstimatedTime.value == "xxx")
	{
	alert("RUN ARMAGH: Please select your estimated finish time");
	theForm.frmEstimatedTime.focus();
	result = false;
	return result;
	}

	if (theForm.frmAffiliated[1].checked == true)
	{
		if (theForm.frmAffiliatedClub.value == "")
		{
		alert("RUN ARMAGH: Please enter your affilicated athletics/running club");
		theForm.frmAffiliatedClub.focus();
		result = false;
		return result;
		}
	}
	
	if (theForm.frmTShirtSize.value == "xxx")
	{
	alert("RUN ARMAGH: Please select the size for your complimentary RUN ARMAGH t-shirt");
	theForm.frmTShirtSize.focus();
	result = false;
	return result;
	}

//	ALL GOOD IF YOU MAKE IT THIS FAR

return true;
}
