// javascript functions to be used in 
// dmillerlaw.com


// Format phone number
function validateNotEmpty(field, msg) {
	var myField = document.getElementById(field);
	if((myField.value == "") || (myField.value == null)) {
		alert(msg);
		return false;
	}
	return true;
}
function validateEmail(email, msg, optional) {
	var myEmail = document.getElementById(email);
	if (!myEmail.value && optional) {
		return true;
	}
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!re_mail.test(myEmail.value)) {
		alert(msg);
		myEmail.focus();
		myEmail.select();
		return false;
	}
	return true;
}
function validateString(myField, msg, min, max) {
	field = document.getElementById(myField);
	if (!min) { min = 1 }
	if (!max) { max = 65535 }
	if (!field.value || field.value.length < min || field.value.max > max) {
		alert(msg);
		field.focus();
		field.select();
		return false;
	}
	return true;
}
