// JavaScript Document

function validateFormEN() {
	var hasErrors = false;
	var errOutput = "The following errors occured with your submission. Please fix these errors and try re-submitting your request:";
	
	$('.validate').each(function (i) {
		// Look for the attribute "check" which tells us 
		// what to check for in the validation process								  
		var checking = $(this).attr("check");
		
		// Available options for checking:
		//		filled - not empty
		//		email - valid email format
		
		
		
		if(checking=="filled") {
			
			if ($(this).val() == "") {
				hasErrors = true;
				var fieldName = $(this).attr("name").replace("_"," ");
				errOutput += "\n- '"+ fieldName +"' is a required field";
			}
			
		} 
		
		if(checking=="email") {			
			var filter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;			
			if ($(this).val() == "" || !filter.test($(this).val())) {
				hasErrors = true;
				errOutput += "\n- Your email address is invalid. Please provide a valid email address.";
			}				
		}
		
		if(checking=="telnum") {
			
			var filter = /^[0-9-()]+$/;			
			if ($(this).val() == "" || !filter.test($(this).val())) {
				hasErrors = true;
				errOutput += "\n- Your phone number is invalid. Please use only numbers or the dash.";
			}		
			
		} 
		
								 
	});
	
	
	if (hasErrors) {
		alert(errOutput);
	} else {
		document.jsSubmitForm.submit();
	}
}