
function clearQuotes(theForm) {
	for (i=0;i<theForm.elements.length;i++) {
		if (theForm.elements[i].value) {
			theForm.elements[i].value = theForm.elements[i].value.replace(/'/gi,"`");
		}
	}
}

function checkEmail(theEmail) {
	if (theEmail.indexOf('.')==-1) return false;
	if (theEmail.indexOf('@')==-1) return false;
	if (theEmail.length<6) return false;
	return true;
}

function checkCompetition() {
	theForm=document.CompetitionForm;
	clearQuotes(theForm);
	
	if (theForm.fname.value.length<1) {alert("Please enter your first name.");return false;}
	if (theForm.lname.value.length<1) {alert("Please enter your last name.");return false;}
	if (theForm.email.value.length<1) {alert("Please enter your email address.");return false;}
	if (checkEmail(theForm.email.value)==false) {alert("The email address you have entered does not seem to be valid.");return false;}

	if (theForm.verificationCode) {
		if (theForm.verificationCode.value.length<1) {alert("Please enter the verification code.");return false;}
	}

	return true;
}

function checkSubscription() {
	theForm=document.SubscriptionForm;
	clearQuotes(theForm);
	
	if (theForm.fname.value.length<1) {alert("Please enter your first name.");return false;}
	if (theForm.lname.value.length<1) {alert("Please enter your last name.");return false;}
	if (theForm.email.value.length<1) {alert("Please enter your email address.");return false;}
	if (checkEmail(theForm.email.value)==false) {alert("The email address you have entered does not seem to be valid.");return false;}

	if (theForm.verificationCode) {
		if (theForm.verificationCode.value.length<1) {alert("Please enter the verification code.");return false;}
	}
	catcount = 0;
	
	for (i = 0; i < theForm.catcount.value; i++)
	{
		index   = (i < 10) ? "0"+i : ""+i;
		cat 	= eval("theForm.cat"+index);

		if (!cat.checked) catcount++
	}
	if (catcount == theForm.catcount.value)
	{
		alert('Please choose at least one newsletter subscription');
		return false;
	}
	return true;
}

function checkEnquiry() {
	theForm=document.EnquiryForm;
	clearQuotes(theForm);
	
	if (theForm.fname.value.length<1) {alert("Please enter your first name.");return false;}
	if (theForm.lname.value.length<1) {alert("Please enter your last name.");return false;}
	if (theForm.email.value.length<1) {alert("Please enter your email address.");return false;}
	if (checkEmail(theForm.email.value)==false) {alert("The email address you have entered does not seem to be valid.");return false;}

	if (theForm.subject.value.length<1) {alert("Please enter a subject for your enquiry.");return false;}
	if (theForm.notes.value.length<1) {alert("Please enter a message.");return false;}

	if (theForm.verificationCode) {
		if (theForm.verificationCode.value.length<1) {alert("Please enter the verification code.");return false;}
	}

	return true;
}

function checkMember() {
	theForm=document.MemberForm;
	clearQuotes(theForm);
	
	if (theForm.fname.value.length<1) {alert("Please enter your first name.");return false;}
	if (theForm.lname.value.length<1) {alert("Please enter your last name.");return false;}
	if (theForm.email.value.length<1) {alert("Please enter your email address.");return false;}
	if (checkEmail(theForm.email.value)==false) {alert("The email address you have entered does not seem to be valid.");return false;}

	if (theForm.password.value.length<1) {alert("Please enter a password.");return false;}
	if (theForm.password2.value.length<1) {alert("Please enter your password again.");return false;}
	if (theForm.password.value != theForm.password2.value) {alert("Your passwords do not match. Please retype them.");return false;}

	if (theForm.verificationCode) {
		if (theForm.verificationCode.value.length<1) {alert("Please enter the verification code.");return false;}
	}

	return true;
}

function checkJoinNow(f)
{
	with(f)
	{
		if (checkEmail(email.value) == false)
		{
			alert("The email address you have entered does not seem to be valid.");
			return false;
		}
	}
	
}


function checkGrantApplication()
{
	f = document.GrantApplicationForm;

	with(f)
	{
		if (fname.value.length<1) {alert("Please enter your first name.");return false;}
		if (lname.value.length<1) {alert("Please enter your last name.");return false;}
		if (dobday.selectedIndex == 0 || dobmonth.selectedIndex == 0 || dobyear.selectedIndex == 0) {alert("Please enter the child's date of birth.");return false;}

		if (guardianfname.value.length<1) {alert("Please enter the parents first name.");return false;}
		if (guardianlname.value.length<1) {alert("Please enter the parents last name.");return false;}

	//	if (org.value.length<1) {alert("Please enter your company/organisation name.");return false;}
		if (street.value.length<1) {alert("Please enter your street.");return false;}
		if (suburb.value.length<1) {alert("Please enter your suburb.");return false;}
		if (postcode.value.length<1) {alert("Please enter your postcode.");return false;}
		if (state.value.length<1) {alert("Please enter your state.");return false;}

		if (email.value.length<1) {alert("Please enter your email address.");return false;}
		if (checkEmail(email.value)==false) {alert("The email address you have entered does not seem to be valid.");return false;}
		if (phone1.value.length<1) {alert("Please enter your phone number.");return false;}
		if (notes.value.length<1) {alert("Please enter a brief description of the purpose for the funds.");return false;}

	}
	return true;
}


function checkGetOnBoard()
{
	f = document.GetOnBoardForm;

	with(f)
	{
		if (fname.value.length<1) {alert("Please enter your first name.");return false;}
		if (lname.value.length<1) {alert("Please enter your last name.");return false;}
		if (street.value.length<1) {alert("Please enter your street.");return false;}
		if (suburb.value.length<1) {alert("Please enter your suburb.");return false;}
		if (postcode.value.length<1) {alert("Please enter your postcode.");return false;}
		if (state.value.length<1) {alert("Please enter your state.");return false;}
		if (email.value.length<1) {alert("Please enter your email address.");return false;}
		if (checkEmail(email.value)==false) {alert("The email address you have entered does not seem to be valid.");return false;}
		if (phone1.value.length<1) {alert("Please enter your phone number.");return false;}
		if (notes.value.length<1) {alert("Please enter a brief description of how you would like to help Strike A Chord and what you can offer.");return false;}

	}
	return true;
}

