function checkWholeForm(theForm) {
    var why = "";
    why += checkForURL( theForm.name.value, "name" );
    why += checkPhone(theForm.phone.value);
    why += checkEmail(theForm.email.value);
    why += checkForURL( theForm.address.value, "postal address" );
    why += checkForURL( theForm.location.value, "location" );
    why += checkForURL( theForm.eventDate.value, "event date" );
    why += checkForURL( theForm.duration.value, "event duration" );
    why += checkForURL( theForm.bestContactTime.value, "time" );
    if (why != "") {
       alert(why);
       return false;
    }
	return true;
}

function checkForURL( strng, field ) {
	var error = "";
	if( strng.length > 120 || strng.indexOf( "http://" ) > -1 ) {
		error = "\"" + strng + "\" is not a valid " + field + ".\n";
	}
	return error;
}

function checkEmail( strng ) {
	var error="";
	if (strng == "") {
	   error = "Please enter your email address.\n";
	}
	
	var emailFilter=/^.+@.+\..{2,3}$/;
	if( !(emailFilter.test(strng)) ) { 
		error = "Please enter a valid email address.\n";
	}
	else {
	// Test email for illegal characters.
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;
		if (strng.match(illegalChars)) {
		  error = "The email address contains illegal characters.\n";
	   }
	}
	return error;    
}

function checkPhone( strng ) {
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	
	if( strng == "" ) {
		return "Please enter a phone number where we can reach you.\n";
	}
	
	// Strip out acceptable non-numeric characters.
	if (isNaN(parseInt(stripped))) {
	   return "\"" + strng + "\" is not a valid phone number.\n";
	}
	
	if (!(stripped.length == 10)) {
		return error = "Please included an area code in your phone number.\n";
	}
	return "";
}