function checkForm() {
    var why = "";
	why += checkFirstname(emailForm.first_name.value);
	why += checkLastname(emailForm.last_name.value);
	why += checkOrganization(emailForm.organization.value);
    why += checkEmail(emailForm.your_email.value);
    why += checkPhone(emailForm.telephone.value);

    if (why != "") {
       alert(why);
       return false;
    }
	return true;
}

function checkFirstname (strng) {
	var error = "";
	if (strng == "") {
	   error = "REQUIRED: You didn't enter your first name.\n";
	}
	return error;
}

function checkLastname (strng) {
	var error = "";
	if (strng == "") {
	   error = "REQUIRED: You didn't enter your last name.\n";
	}
	return error;
}   

function checkEmail (strng) {
	var error="";
	if (strng == "") {
	   error = "REQUIRED: You didn't enter an email address.\n";
	}

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

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

	var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); 
	if (isNaN(parseInt(stripped))) {
	   error = "REQUIRED: The phone number contains illegal characters.";
	}
	if (!(stripped.length == 10)) {
		error = "REQUIRED: The phone number is the wrong length. Please make sure you included an area code.\n";
	} 
	return error;
}   

function checkOrganization(strng) {
	var error = "";
	if (strng == "") {
		error = "REQUIRED: You didn't enter an Organization.\n"
	}
	return error;	  
}
