// First Name check uc, lc, and underscore only.

function checkFirstname (strng) {
var error = "";
if (strng == "") {
	error = "Please enter a first name.\n";
	}
//	var illegalChars = /\w+/; // allow letters, numbers, and underscores
//	if (!(strng.search(/[a-zA-Z0-9_]+(-[a-zA-Z0-9_]+)*/))) {
//	error = "The " + pos + " name contains illegal characters.\n";
//	} 
return error;
}		


// Last Name check uc, lc, and underscore only.

function checkLastname (strng) {
var error = "";
if (strng == "") {
	error = "Please enter a last name.\n";
	}
return error;
}  


// title

function checkTitle (strng) {
var error = "";
if (strng == "") {
	error = "Please enter a title.\n";
	}
return error;
}


// company

function checkCompany (strng) {
var error = "";
if (strng == "") {
	error = "Please enter a company.\n";
	}
return error;
}


// city

function checkCity (strng) {
var error = "";
if (strng == "") {
	error = "Please enter a city.\n";
	}
return error;
}

function checkFeedback (strng) {
var error = "";
if (strng == "") {
	error = "Please enter your feedback.\n";
	}
return error;
}


// valid selector from dropdown list

function checkDropdown(choice, list) {
var error = "";
	if (choice == 0) {
	error = "Please choose an option from the " + list + " menu.\n";
	}
return error;
}


// phone - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
	error = "Please enter a phone number.\n";
	}

//var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
//	if (isNaN(parseInt(stripped))) {
//	error = "The phone number contains illegal characters.\n";
//	}
return error;
}


// email

function checkEmail (strng) {
var error="";
if (strng == "") {
	error = "Please enter an email address.\n";
}

	var emailFilter=/^.+@.+\..{2,4}$/;
	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 checkWholeForm(cheese) {
	var what = "";
	what += checkEmail(cheese.email.value);
	what += checkFeedback(cheese.why.value);
	//what += checkDropdown(cheese.menu_name.value, 'Type of Benefit');
	if (what != "") {
	   alert(what);
	   return false;
	}
return true;
}
