
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 checkStandardValues(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;}
	return true;
}

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

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

function checkGeneric()
{
	theForm=document.getElementById("GenericForm");

	clearQuotes(theForm);
	
	if (!checkStandardValues(theForm)) return false;
	if (!checkVerificationCode(theForm)) return false;

	return true;
}
function checkSubscription()
{
	theForm=document.getElementById("SubscriptionForm");
	clearQuotes(theForm);
	
	if (!checkStandardValues(theForm)) return false;
	if (!checkVerificationCode(theForm)) 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.getElementById("EnquiryForm");
	clearQuotes(theForm);
	
	if (!checkStandardValues(theForm)) 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 (!checkVerificationCode(theForm)) return false;

	return true;
}

function checkMember()
{
	theForm=document.getElementById("MemberForm");
	clearQuotes(theForm);
	
	if (!checkStandardValues(theForm)) 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 (!checkVerificationCode(theForm)) 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;
		}
	}
	
}
