function checkForm(form) {	
	
	var errorMsg = "";
	var cmsReg = "(^(cma|wcm)\$)";

	errorMsg += isFieldValid(form.contactName.value,"Contact name",0,50,"text");
	errorMsg += isFieldValid(form.balletSchool.value,"School name",0,50,"alphaNum");
	errorMsg += isFieldValid(form.phone.value,"Contact number",0,10,"numOnly");
	errorMsg += isFieldValid(form.emailAddress.value,"Email address",0,80,"email");
	errorMsg += isFieldValid(form.feedbackQuery.value,"Feedback/Query",1,500,"alphaNum");


	errorMsg += isFieldValid(form.cms.value,"cms",0,3,"custom",cmsReg);

	if (form.cms.value == "cma")
	{
		errorMsg += isFieldValid(form.thankYouPage.value,"Thank you page",0,6,"num");
	}



	return errorMsg;
}

function submitForm(form) {
	var errorMsg = checkForm(form);
	var reEnterMsg = " <p>Please click the 'Close' button and complete the missing fields.</p>";

	if (isEmpty(errorMsg)) {
		form.submit();   
	} else {
		popup = window.open("","Ballet_Community_Feedback","width=400,height=350,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>Ballet Community Feedback</title>");
		popup.document.write("<body>");
		popup.document.write("<strong>Ballet Community Feedback</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();
	}
}
