function checkForm(theForm) {
    var why = "";  
    why += checkText(theForm.firstname.value, "your first name.");
    why += checkText(theForm.lastname.value, "your last name.");
    why += checkText(theForm.topic.value, "a topic.");
    why += checkText(theForm.comments.value, "a comment.");
    why += checkEmail(theForm.email.value);
    
    if (why != "") {
       alert(why);
       return false;
    }
 
return true;
}


function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Please enter a valid 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 checkText (strng, formfield) {
 var error = "";
 if (strng == "") {
    error = "Please enter " + formfield + "\n";
 }
 return error;
 }

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

 
	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 not a complete phone number with area code.\n";
	}
 
 	return error;
 }


function checkDropdown(choice, strng) {
    var error = "";
    if (choice == "") {
       error = strng + "\n";
    }    
return error;
}    

