

function checkContactForm(contact_form) {
	var why = "";
	why += checkName(document.forms.contact_form.name.value);
	why += checkEmail(document.forms.contact_form.email.value);
	why += checkComments(document.forms.contact_form.comments.value);
	
	
	if (why != "") {
	   alert(why);
	   return false;
	}else{
		return true;
	}
}

function checkIdeaMachineForm(ideaMachineForm) {
	var why = "";
	why += checkEmail(document.forms.ideaMachineForm.email.value);
	
	if (why != "") {
	   alert(why);
	   return false;
	}else{
		return true;
	}
}



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;    
}

function checkComments(strng) {
	//alert(strng);
	var error = "";
	if (strng == "") {
		error = "Please enter your comment or question.\n";
	}
	if (strng == " ") {
		error = "Please enter your comment or question.\n";
	}
	return error;
	
}

function checkName(strng) {
	//alert(strng);
	var error = "";
	if (strng == "") {
		error = "Please enter your name.\n";
	}
	if (strng == " ") {
		error = "Please enter your name.\n";
	}
	return error;
	
}
