function idSubmit(formName) {
	if (idChkFields(formName) == false) { return false; }
	else { document.forms[formName].submit(); }
}

function idChkFields(formName) {
	for (i=0; i<document.forms[formName].length; i++) {
		what = eval(document.forms[formName].elements[i]);
		if (what.e_valid_msg || what.e_exists_msg || what.e_email_msg || what.e_regexp_msg || what.e_function_msg || what.e_num_msg) { 
			if (what.e_valid && what.e_valid_msg) {
				if (what.value != what.e_valid) {
					alert(what.e_valid_msg);
					if (what.type != 'hidden') { what.focus(); }
					return false;
				}
			}
			if (what.e_exists && what.e_exists_msg) {
				if (what.value == "") {
					alert(what.e_exists_msg);
					if (what.type != 'hidden') { what.focus(); }
					return false;
				}
			}
			if (what.e_email && what.e_email_msg) {
				if (what.value) {
					var filter = /^([a-zA-Z0-9_\.\'\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;  
					if (!filter.test(what.value)) { 
						alert(what.e_email_msg);
						if (what.type != 'hidden') { what.focus(); }
						return false; 
					}
				}
			}
			if (what.e_regexp && what.e_regexp_msg) {
				if (what.value) {
					if (what.value.search(what.e_regexp) == -1) {
						alert(what.e_regexp_msg);
						if (what.type != 'hidden') { what.focus(); }
						return false;
					}
				}
			}
			if (what.e_function && what.e_function_msg) {
				if (!eval(what.e_function)) {
					alert(what.e_function_msg);
					if (what.type != 'hidden') { what.focus(); }
					return false;
				}
			}
			if (what.e_num && what.e_num_msg) {
				if (what.value.search(/^[0-9]+$/) == -1) {
					alert(what.e_num_msg);
					if (what.type != 'hidden') { what.focus(); }
					return false;
				}
			}
		}
		if (what.dateName) { 
			if (!idChkDate(formName, what.dateName)) { return false; }
		}
		if (what.phoneName) {
			if (!idChkPhone(formName, what.phoneName)) { return false; }
		}
	}
	if (window.chkExtra) { return chkExtra(); }
	return true;
}

function idChkDate(form, which) {
	month = eval('document.' + form + '.' + which + 'Month');
	day = eval('document.' + form + '.' + which + 'Day');
	year = eval('document.' + form + '.' + which + 'Year');
	retVal = true;
	if (month.value != '' || day.value != '' || year.value != '') {
		if (month.value == '' || day.value == '' || year.value == '') {
			alert("You must enter the " + month.dateLabel + " in full");
			if (month.value == '') { month.focus(); }
			else if (day.value == '') { day.focus(); }
			else if (year.value == '') { year.focus(); }
			retVal = false;
		}
	}
	return retVal;
}

function idChkPhone(form, which) {
	idChkPhone1 = eval('document.' + form + '.' + which + '1');
	idChkPhone2 = eval('document.' + form + '.' + which + '2');
	idChkPhone3 = eval('document.' + form + '.' + which + '3');
	retVal = true;
	if (idChkPhone1.value != '' || idChkPhone2.value != '' || idChkPhone3.value != '') {
		if (idChkPhone1.value == '' || idChkPhone2.value == '' || idChkPhone3.value == '') {
			alert("You must enter the " + idChkPhone1.phoneLabel + " in full");
			if (idChkPhone1.value == '') { idChkPhone1.focus(); }
			else if (idChkPhone2.value == '') { idChkPhone2.focus(); }
			else if (idChkPhone3.value == '') { idChkPhone3.focus(); }
			retVal = false;
		}
		else if (isNaN(idChkPhone1.value) || isNaN(idChkPhone2.value) || isNaN(idChkPhone3.value)) {
			alert("Invalid " + idChkPhone1.phoneLabel + " format");
			if (isNaN(idChkPhone1.value)) { idChkPhone1.focus(); }
			else if (isNaN(idChkPhone2.value)) { idChkPhone2.focus(); }
			else if (isNaN(idChkPhone3.value)) { idChkPhone3.focus(); }
			retVal = false;
		}
		else if (idChkPhone1.value.length < 3 || idChkPhone2.value.length < 3 || idChkPhone3.value.length < 4) {
			alert("Invalid " + idChkPhone1.phoneLabel + " format");
			if (idChkPhone1.value.length < 3) { idChkPhone1.focus(); }
			else if (idChkPhone2.value.length < 3) { idChkPhone2.focus(); }
			else if (idChkPhone3.value.length < 4) { idChkPhone3.focus(); }
			retVal = false;
		}
	}
	return retVal;
}

function idPhoneTab(which, length, next, event) {
	if (event.keyCode >= 48 && event.keyCode <= 57) {
		if (which.value.length == length) {
			nextField = eval("document." + next);
			nextField.focus();
		}
	}
}