function checkEmail (strng,fieldName,msg) {
	document.getElementById(fieldName).style.backgroundColor="#fff";
	var error="";
	var emailFilter=/^.+@.+\..{2,4}$/;
	// edited above regex to increase possible tld characters to 4 (ie, .info, .aero, .coop, .mobi, etc)
	var illegalChars= /[\/\(\)\<\>\,\;\:\\\"\[\]]/
	if (strng == "") {
		error = "You didn't enter an email address.\n";
		document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
	} else if (!(emailFilter.test(strng))) { 
		error = "Please enter a valid email address.\n";
		document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
	} else if (strng.match(illegalChars)) {
	//test email for illegal characters
		error = "The email address contains illegal characters.\n";
		document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
	}
	return error;    
}

function checkAllNumbers (strng,fieldName,stringLength,msg) {
	document.getElementById(fieldName).style.backgroundColor="#fff";
	var error = "";
	if (strng == "") {
		error = "You didn't enter " + msg + ".\n";
		document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
	} else if (strng.match(/\D/)) {
		error = "The " + msg + " must be all numbers.\n";
		document.getElementById(fieldName).style.backgroundColor="#FFD3D3";	
	} else if ((strng.length < stringLength)) {
		error = "The " + msg + " is too short. It must be " + stringLength + " digits long.\n";
		document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
	}
	return error;
}

function checkName (strng,fieldName,msg) {
	document.getElementById(fieldName).style.backgroundColor="#fff";
	var error = "";
	if (strng == "") {
		error = "You didn't enter " + msg + ".\n";
		document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
	}
	return error;
}       

function isEmpty(strng,fieldName,msg) {
	document.getElementById(fieldName).style.backgroundColor="#fff";
var error = "";
  if (strng.length == 0) {
     error = msg + " has not been filled in.\n"
	document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
  }
return error;	  
}

// valid selector from dropdown list
function checkDropdown(choice,fieldName,msg) {
	document.getElementById(fieldName).style.backgroundColor="#fff";
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from " + msg + " list.\n";
	document.getElementById(fieldName).style.backgroundColor="#FFD3D3";
    }    
return error;
}

function checkCheckBoxes (fieldName,stringLength,divID,msg) {
// make certain the checkbox set is in a div for IDing the error...
	var error = "";
	var checkArray = document.getElementsByName(fieldName);
	var checkbox_choices = 0;
	for (counter = 0; counter < checkArray.length; counter++) {	
		if (checkArray[counter].checked) checkbox_choices = checkbox_choices + 1;
	}
	if (checkbox_choices < stringLength) {
		error = "Please select at least " + stringLength +  " check boxes about " + msg + ".\n";
		document.getElementById(divID).style.backgroundColor="#FFD3D3";
	}
	return error;
}

function acceptCheckBox (fieldName,stringLength,divID,msg,bgcolor) {
// make certain the checkbox set is in a div for IDing the error...
	var error = "";
	var checkArray = document.getElementsByName(fieldName);
	document.getElementById(divID).style.backgroundColor="#" + bgcolor;
	var checkbox_choices = 0;
	for (counter = 0; counter < checkArray.length; counter++) {	
		if (checkArray[counter].checked) checkbox_choices = checkbox_choices + 1;
	}
	if (checkbox_choices < stringLength) {
		error = "You must accept and check the " + msg + ".\n";
		document.getElementById(divID).style.backgroundColor="#FFD3D3";
	}
	return error;
}

function checkRadio (fieldName,divID,msg,bgcolor) {
// make certain the radiobutton set is in a div for IDing the error...
	var error = "";
	var checkArray = document.getElementsByName(fieldName);
	document.getElementById(divID).style.backgroundColor="#" + bgcolor;
	var checkbox_choices = 0;
	for (counter = 0; counter < checkArray.length; counter++) {	
		if (checkArray[counter].checked) checkbox_choices = checkbox_choices + 1;
	}
	if (checkbox_choices == 0) {
		error = "Please select " + msg + ".\n";
		document.getElementById(divID).style.backgroundColor="#FFD3D3";
	}
	return error;
}
