
function isValidPhone(val)
{
	var cnt = 0;
	var illegal = "N";
	for (i=0; i<val.length; i++) {
		var c = val.charAt(i);
		if (c >= "0" && c <= "9") { cnt++; 
		} else {
			if (c!=" " && c!="-" && c!="(" && c!= ")") { illegal = "Y"; }
		}
	}
	if (cnt < 7) return 1;
	else if (illegal == "Y") return 2;  
	else return 0;
}

function checkrequired(which) {
	var error = "";
	var val = document.getElementById("Required Email").value;
	var val2 = document.getElementById("Required Daytime Phone").value;
	var val3 = document.getElementById("Required Evening Phone").value;

	document.ContactForm.psmFrom.value = val;var pass=true;
	if ( (val.indexOf(".") < 2) || (val.indexOf("@") < 1) ) {
		error += "The Email Address does not appear to be valid.\n"
	}
	var dphone = isValidPhone(val2);
	if (dphone == 1) { error += "The Daytime Phone must contain at least 7 digits.\n"; }
	if (dphone == 2) { error += "The Daytime Phone contains illegal characters.\n"; }
	var ephone = isValidPhone(val3);
	if (ephone == 1) { error += "The Evening Phone must contain at least 7 digits.\n"; }
	if (ephone == 2) { error += "The Evening Phone contains illegal characters.\n"; }

	if (error > "") {
		alert(error);
		return false;
	} else {
		if (document.images) {
			for (i=0;i<which.length;i++) {
				var tempobj=which.elements[i];
				if (tempobj.name.substring(0,8)=="Required") {
					if (((tempobj.type=="text"||tempobj.type=="textarea")&& tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
	tempobj.selectedIndex==0)) {
						shortFieldName=tempobj.name.substring(8,30).toUpperCase();
						error += "Please make sure the"+shortFieldName+" field was properly completed.\n";
					}
				}
			}
		}

		if (error > "") {
			alert(error);
			return false;
		} else {
			return true;
		}
	}
}
