
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 checkEnquiry() {
	theForm=document.EnquiryForm;
	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;}

	var checkSum=0;
	if (theForm.phone1.value.length>0) checkSum++;
	if (theForm.phone2.value.length>0) checkSum++;
	if (theForm.mobile.value.length>0) checkSum++;
	if (checkSum==0) {alert("Please enter a contact phone number (home, work or mobile).");theForm.phone1.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.data00.value.length<1)  {alert("Please enter your gross income.");theForm.data00.focus();return false;}

	if (theForm.data02.value.length<1)  {alert("Please enter the total of any existing loans.");theForm.data02.focus();return false;}
	if (theForm.data03.value.length<1)  {alert("Please enter your credit card limit.");theForm.data03.focus();return false;}
	if (theForm.data04.value.length<1)  {alert("Please enter your total monthly outgoings.");theForm.data04.focus();return false;}
	if (theForm.data05.value.length<1)  {alert("Please enter deposit.");theForm.data05.focus();return false;}

	checkSum=0;
	var theChecks=document.getElementById('detailsPurpose').getElementsByTagName('input');
	for (i=0;i<theChecks.length;i++) {
		if (theChecks[i].type=="checkbox" && theChecks[i].checked==true) checkSum++;
	}
	if (checkSum==0) {alert("Please indicate the purpose of the loan.");theForm.data08.focus();return false;}

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

	return true;
}

