function checkForm(form) {
	
	var errorMsg = "";
	var titleReg = "(^(Mr|Mrs|Ms|Miss|Other)\$)";
	var stateReg = "(^(ACT|NSW|NT|QLD|SA|TAS|VIC|WA|Other)\$)";
	var contactMethodReg = "(^(Email|Phone\$))";
	var contactTimeReg = "(^(Morning|Afternoon|Evening\$))";	
	var prefTelReg = "(^(Mobile|Private|Business)\$)";
	var yesNoReg = "(^(Yes|No)\$)";

	var theDate = new Date();
	var currentYear = theDate.getFullYear();
	var nextYear = currentYear + 1;
	var contactYearReg = "(" + currentYear +"|"+nextYear+ ")";

	var otherTitleMandatory = 0;
	var otherStateMin = 0;

	if (getSelectedOptionValue(form.title) == "Other") {
		otherTitleMandatory = 1;
	}

errorMsg += isFieldValid(getSelectedOptionValue(form.title),"Your details - Title",1,5,"optionsList",titleReg);
errorMsg += isFieldValid(form.otherTitle.value,"Your details - Other Title",otherTitleMandatory,15,"text");
errorMsg += isFieldValid(form.firstName.value,"Your details - First name",1,50,"text");
errorMsg += isFieldValid(form.surname.value,"Your details - Surname",1,50,"text");
errorMsg += isFieldValid(form.businessName.value,"Your details - Business name",1,60,"alphanum");
errorMsg += isFieldValid(form.address.value,"Your details - Address",0,80,"alphaNum");
errorMsg += isFieldValid(form.suburb.value,"Your details - Suburb",0,50,"text");
errorMsg += isFieldValid(getSelectedOptionValue(form.state),"Your details - State",1,5,"custom",stateReg);

if (getSelectedOptionValue(form.state) == "Other") {
	otherStateMin = 1;
}

errorMsg += isFieldValid(form.otherState.value,"Your details - State (Other)",otherStateMin,30,"text");

if (form.country.value == "Australia" || form.country.value == "australia" || form.country.value == "") {
	errorMsg += isFieldValid(form.postcode.value,"Your details - Postcode",0,4,"num");
} else {
	errorMsg += isFieldValid(form.postcode.value,"Your details - Postcode",0,10,"alphaNum");
}

errorMsg += isFieldValid(form.country.value,"Your details - Country",0,50,"text");

errorMsg += isFieldValid(getSelectedOptionValue(form.prefPhone),"Your contact information -  Preferred telephone no.",1,10,"optionsList",prefTelReg);
errorMsg += isFieldValid(form.phone.value,"Your contact information -  Telephone number",10,14,"num");
errorMsg += isFieldValid(form.emailAddress.value,"Your contact information -  Email",1,80,"email");
errorMsg += isFieldValid(getSelectedOptionValue(form.contactMethod),"Your contact information - Preferred contact method",0,5,"optionsList",contactMethodReg);
errorMsg += isFieldValid(getSelectedOptionValue(form.contactTime),"Your contact information - Preferred contact time",0,9,"optionsList",contactTimeReg);
errorMsg += isFieldValid(getRadioButtonValue(form.nabCustomer),"Your contact information - Existing NAB customer?",0,3,"optionsList",yesNoReg);
errorMsg += isFieldValid(form.branch.value,"Your contact information - NAB business banking centre",0,50,"alphanum");
errorMsg += isFieldValid(form.bankerName.value,"Your contact information - NAB business banker",0,50,"text");

if (eval(form.information5.checked) == true) { form.information5.value = "National EFTPOS"; } else { form.information5.value = ""; }
if (eval(form.information1.checked) == true) { form.information1.value = "National Locked Box"; } else { form.information1.value = ""; }
if (eval(form.information6.checked) == true) { form.information6.value = "National Direct Debit"; } else { form.information6.value = ""; }
if (eval(form.information7.checked) == true) { form.information7.value = "National RentCard"; } else { form.information7.value = ""; }
if (eval(form.information10.checked) == true) { form.information10.value = "National IVR Interactive Voice Response"; } else { form.information10.value = ""; }
if (eval(form.information3.checked) == true) { form.information3.value = "National BPAY"; } else { form.information3.value = ""; }
if (eval(form.information12.checked) == true) { form.information12.value = "National Accounts Payable Systems NAPS"; } else { form.information12.value = ""; }
if (eval(form.information11.checked) == true) { form.information11.value = "National Direct Credit"; } else { form.information11.value = ""; }
if (eval(form.information9.checked) == true) { form.information9.value = "NAB Multipay"; } else { form.information9.value = ""; }

if (eval(form.information20.checked) == true) { form.information20.value = "National Transact"; } else { form.information20.value = ""; }

if ((eval(form.information5.checked) != true) && (eval(form.information1.checked) != true) && (eval(form.information6.checked) != true) && (eval(form.information7.checked) != true) && (eval(form.information10.checked) != true) && (eval(form.information3.checked) != true) && (eval(form.information12.checked) != true) && (eval(form.information11.checked) != true) && (eval(form.information9.checked) != true) && (eval(form.information20.checked) !=true)) {
	errorMsg += "<p>At least one of the <strong>Payment Solutions</strong> you are interested in must be selected</p>";
}

errorMsg += isFieldValid(form.comments.value,"Your enquiry -  Additional comments",0,1000,"alphaNum");
errorMsg += isFieldValid(form.thankYouPage.value,"Thankyou page not defined",0,6,"num");

return errorMsg;

}

function submitForm(form) {
	var errorMsg = checkForm(form);
	var reEnterMsg = " <p> Please click the 'Close' button and reenter it.</p>";
	
	if (isEmpty(errorMsg)) {
		form.submit();
	} else {
		popup = window.open("","paymentSolutions_win","width=400,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1");
		popup.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head>");
		popup.document.write("<link rel='stylesheet' href='/css/National/GlobalStyle.css' type='text/css'></head>");
		popup.document.write("<title>Payment solutions enquiry</title>");
		popup.document.write("<body>");
		popup.document.write("<strong>Payment solutions enquiry</strong><br><br>");
		popup.document.write(errorMsg);
		popup.document.write("<br>");
		popup.document.write(reEnterMsg);
		popup.document.write("<center><form><input type=button value=Close onClick=javascript:window.close();></center></form>");
		popup.document.write("</body>");
		popup.document.write("</html>");
		popup.document.close();
	}
}

