
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;}

	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;}

	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.message.value.length<1) {alert("Please enter a message.");return false;}

	return true;
}
function checkRequest()
{
	theForm=document.RequestForm;
	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;}

	return true;
}
function checkAlerts() {
	theForm=document.getElementById("AlertsForm");
	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;}

	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 checkApplication() {
	theForm=document.ApplicationForm;
	clearQuotes(theForm);

	if (theForm.fname.value.length<1)  {alert("Please enter your first name.");			theForm.fname.focus();		return false;}
	if (theForm.lname.value.length<1)  {alert("Please enter your last name.");			theForm.lname.focus();		return false;}
	if (theForm.street.value.length<1) {alert("Please enter your street and number.");	theForm.street.focus();		return false;}
	if (theForm.suburb.value.length<1) {alert("Please enter your town or suburb.");		theForm.suburb.focus();		return false;}
	if (theForm.postcode.value.length<1) {alert("Please enter your post or zip code.");	theForm.postcode.focus();	return false;}
	if (theForm.state.value.length<1) {alert("Please enter your state or region.");		theForm.state.focus();		return false;}
	if (theForm.country.selectedIndex==0) {alert("Please select your country.");		theForm.country.focus();	return false;}
	if (theForm.email.value.length<1) {alert("Please enter your email address.");		theForm.email.focus();		return false;}
	if (checkEmail(theForm.email.value)==false) {alert("The email address you have entered does not seem to be valid.");	theForm.email.focus();	return false;}
	if (theForm.phone1.value.length<1) {alert("Please enter a contact phone number.");	theForm.phone1.focus();		return false;}

	if (theForm.streetno.value.length<1) {alert("Please enter the street or lot number of the complex housing your Park Home.");	theForm.streetno.focus();		return false;}
	if (theForm.pstreet1.value.length<1) {alert("Please enter the street name of the complex housing your Park Home.");				theForm.pstreet1.focus();		return false;}
	if (theForm.psuburb.value.length<1) {alert("Please enter the town or suburb of your Park Home.");								theForm.psuburb.focus();		return false;}
	if (theForm.ppostcode.value.length<1) {alert("Please enter the post or zip code of your Park Home.");							theForm.ppostcode.focus();		return false;}

	if (theForm.headline.value.length<1) {alert("Please enter a headline for your Park Home.");			theForm.headline.focus();		return false;}
	if (theForm.description.value.length<1) {alert("Please enter a description of your Park Home.");	theForm.description.focus();	return false;}

	if (theForm.frontage.value.length<1) {alert("Please enter the width of your Park Home.");			theForm.frontage.focus();		return false;}
	if (theForm.depth.value.length<1)    {alert("Please enter the depth of your Park Home.");			theForm.depth.focus();		    return false;}


	return true;
}