function checkForm(form) {
	
	var errorMsg = "";
	var sourceReg = "(^(Nippon Keizai Newspaper|Asahi Newspaper|Yomiyuri Newspaper|Mainichi Newspaper|Sankei Newspaper|Subway|Internet|Friend or acquaintance|other)\$)";
	var interestReg = "(^(Foreign Currency Term Deposits|Overseas Remittances|other)\$)";
	var otherMin = 0;
errorMsg += isFieldValid(form.thankYouPage.value,"Thank you page",1,6,"num");
errorMsg += isFieldValid(form.givenName.value,"Given Name",1,30,"text");
errorMsg += isFieldValid(form.surname.value,"Surname",1,30,"text");
errorMsg += isFieldValid(form.customerCode.value,"Customer Code",0,30,"alphaNum");
errorMsg += isFieldValid(form.address.value,"Address",1,50,"alphaNum");
errorMsg += isFieldValid(form.emailAddress.value,"Your email address",1,50,"email");
errorMsg += isFieldValid(form.countryCode.value,"Phone country code",0,3,"num");
errorMsg += isFieldValid(form.phone.value,"Phone Number",0,15,"num");
errorMsg += isFieldValid(form.source.value,"Select Source",1,23,"optionsList",sourceReg);
errorMsg += isFieldValid(form.interest.value,"Select Interest",1,30,"optionsList",interestReg);
if (form.interest.value == "other") {
	otherMin = 1;
}
errorMsg += isFieldValid(form.other.value,"Other",otherMin,100,"alphaNum");

	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("","appRequest_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/NABAsia/ContentStyle.css' type='text/css'></head>");
		popup.document.write("<title>Application Request Form</title>");
		popup.document.write("<body><div class='validationMsg'>");
		
		popup.document.write("<strong>Application Request Form</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("</div></body>");
		popup.document.write("</html>");
		popup.document.close();
	}
}

