function checkWholeForm(theForm,q1,q2,q3,q4) {
	var why = "";
	why += nameEmpty(theForm[q1].value);
	why += companyEmpty(theForm[q2].value);
	why += phoneEmpty(theForm[q3].value);
	why += emailEmpty(theForm[q4].value);
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function nameEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your name.\n"
  }
return error;	  
}

// company
function companyEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your company.\n"
  }
return error;	  
}

// phone number - strip out delimiters and check for 10 digits
function phoneEmpty(strng) {
var error = "";
	if (strng == "") {
	   error = "Please enter a phone number.\n";
	}else{
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
		if (isNaN(parseInt(stripped))) {
		   error = "The phone number contains illegal characters.";
		}
		if (!(stripped.length == 10)) {
		error = "The phone number is the wrong length. Make sure you included an area code.\n";
		} 
	}
return error;
}

// email
function emailEmpty (strng) {
	var error="";
	if (strng == "") {
   		error = "Please enter your e-mail address.\n";
	} else {
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { 
		   error = "Please enter a valid e-mail address.\n";
		} else {    
			//test email for illegal characters
			var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
			if (strng.match(illegalChars)) {
				error = "The e-mail address contains illegal characters.\n";
			}	
		}
	}
return error;    
}

