// JavaScript
function checkForm(theForm) {
    var why = "";
    why += checkEmail(theForm.email.value);
	why += checkData(theForm.firstName.value, "Please enter a first name into the form. \n");
	why += checkData(theForm.lastname.value, "Please enter a last name into the form. \n");
	why += checkData(theForm.mailingAddress.value, "Please enter an address into the form. \n");
	why += checkData(theForm.city.value, "Please enter a city into the form. \n");
	why += checkData(theForm.postalcode.value, "Please enter a postal code into the form. \n");
	why += checkData(theForm.country.value, "Please enter a country into the form. \n");
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkData (strng, error) {
	if (strng == "") {
 	  return error;
	}else{
		return "";
	}
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an 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;    
}

// friendsEmail