var emailRe = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
var emailV="";
var phoneV="";
var subjectV="";
var enquiryDetsV="";
var alertField="";//variable used to check if all fields have been completed
function contactCheck()
{
var nameV="";
var sourceV="";
	if(document.contactform.bodycontent.value == "")
		{
			if(document.contactform.name.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					nameV = "\n> Contact Name";	
				}
			if (!emailRe.test(document.contactform.email.value))
				{
					emailV = "\n> Email Address is missing or invalid";	
				}
			if(document.contactform.phone.value == "")
			//if the email field is blank returns the following lines text to the email variable
				{
					phoneV = "\n> Contact Phone Number";	
				}
			if(document.contactform.source.value == "")
			//if the email field is blank returns the following lines text to the email variable
				{
					sourceV = "\n> Where did you hear about Accrete";	
				}
			if(document.contactform.subject.value == "")
			//if the email field is blank returns the following lines text to the email variable
				{
					subjectV = "\n> Subject";	
				}
			if(document.contactform.enquiryDets.value == "")
			//if the email field is blank returns the following lines text to the email variable
				{
					enquiryDetsV = "\n> Enquiry Details";	
				}
		if(nameV != "" || emailV != "" || phoneV != "" || sourceV != ""  || subjectV != "" || enquiryDetsV != "" )		    //checks to see if either of the fields in the form contact name, contact number, email address is blank if so    	evaluates to true and returns the following indicator to the variable
				{
					alertField = "Missing Fields";
				}
			if(alertField != "")//checks to see if either variable content evaluates to true if so the following alert is launched
				{
					alert("The following fields needs to be completed: " + nameV + subjectV + emailV + phoneV + sourceV + enquiryDetsV);
				}
			if(alertField != "Missing Fields")
						{
						document.forms[0].submit();
						}
							return false;
		}
		else
			{
			location.href="http://www.accretefinance.com.au/thankyou.cfm";	
			}
}
function enquireCheck()
{
var namef="";
var names="";
var addressV="";
var suburbV="";
var stateV="";
var postcodeV="";
var maritalV="";
var loanpurposeV="";
var firsthomeV="";
var income1V="";
var clearcreditV="";
var sourceV="";

	if(document.enquiryform.bodycontent.value == "")
		{
			if(document.enquiryform.firstname.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					namef = "\n> First Name";	
				}
			if(document.enquiryform.surname.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					names = "\n> Surname";	
				}
			if(document.enquiryform.address.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					addressV = "\n> Address";	
				}
			if(document.enquiryform.suburb.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					suburbV = "\n> Suburb";	
				}
			if(document.enquiryform.state.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					stateV = "\n> State";	
				}
			if(document.enquiryform.postcode.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					postcodeV = "\n> Postcode";	
				}
			if (!emailRe.test(document.enquiryform.email.value))
				{
					emailV = "\n> Email Address is missing or invalid";	
				}
			if(document.enquiryform.phone.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					phoneV = "\n> Contact Number";	
				}
			if(document.enquiryform.maritalstatus.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					maritalV = "\n> Marital Status";	
				}
			if(document.enquiryform.loanpurpose.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					loanpurposeV = "\n> Loan Purpose";	
				}
			if(document.enquiryform.firsthome.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					firsthomeV = "\n> First Home Buyer";	
				}
			if(document.enquiryform.income1.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					income1V = "\n> Gross Annual Income Applicant 1";	
				}
			if(document.enquiryform.credithistory.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					clearcreditV = "\n> Clear Credit History";	
				}
			if(document.enquiryform.source.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					sourceV = "\n> Where Did You Hear About Accrete?";	
				}
			if(namef != "" || names != "" || addressV != "" || suburbV != ""  || stateV != "" || postcodeV != "" || emailV != "" || phoneV != "" || maritalV != "" || loanpurposeV != "" || firsthomeV != "" || income1V != "" || clearcreditV != "" || sourceV != "" )		    //checks to see if either of the fields in the form contact name, contact number, email address is blank if so    	evaluates to true and returns the following indicator to the variable
				{
					alertField = "Missing Fields";
				}
			if(alertField != "")//checks to see if either variable content evaluates to true if so the following alert is launched
				{
					alert("The following fields needs to be completed: " + namef + names + addressV + suburbV + stateV + postcodeV + emailV + phoneV + maritalV + loanpurposeV + firsthomeV + income1V + clearcreditV + sourceV);
				}
			if(alertField != "Missing Fields")
						{
						document.forms[0].submit();
						}
							return false;
		}
		else
			{
			location.href="http://www.accretefinance.com.au/thankyou.cfm";	
			}
}
function careerCheck()
{
var namef="";
var names="";
	if(document.career.bodycontent.value == "")
		{
			
			if(document.career.firstname.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					namef = "\n> First Name";	
				}
			if(document.career.surname.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					names = "\n> Surname";	
				}
			if (!emailRe.test(document.career.email.value))
				{
					emailV = "\n> Email Address is missing or invalid";	
				}
			if(document.career.phone.value == "")
			//if the contact name field is blank returns the following lines text to the contactName variable
				{
					phoneV = "\n> Contact Number";	
				}
			if(namef != "" || names != "" || emailV != "" || phoneV != "" )//checks to see if either of the fields in the form contact name, contact number, email address is blank if so    	evaluates to true and returns the following indicator to the variable
				{
					alertField = "Missing Fields";
				}
			if(alertField != "")//checks to see if either variable content evaluates to true if so the following alert is launched
				{
					alert("The following fields needs to be completed: " + namef + names + emailV + phoneV);
				}
			if(alertField != "Missing Fields")
						{
						document.forms[0].submit();
						}
							return false;
		}
		else
			{
			location.href="http://www.accretefinance.com.au/thankyou.cfm";	
			}
}




