var minWordCount=50;

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"").replace(/\s+/g," ");
}
function checkEmail(email) {
	var filter=/^[^ @<>]+@[^ @<>]+\.[a-z]{2,}$/i;
	email=email.trim();
	if(filter.test(email)==false) {
		sendAnyway=confirm("You seem to have provided an invalid e-mail address.\nDo you want to send your message anyway?");
		if(!sendAnyway) return(false);
	}
	return(true);
}
function check(form) {
	var words=form._DESC_.value.split(" ");
	var wordCount=words.length;
	var msg="";
	if(form._NAME_U_.value=="" && form._NAME_J_.value=="" && form._ALIAS_U_.value=="" && form._ALIAS_J_.value=="") {
		alert("You forgot to put the name of the character!"); 
		return(false);
	}
	if((form._ANIME_U_.value=="")&&(form._ANIME_J_.value=="")) {
		alert("You forgot to put the title of the anime!"); 
		return(false);
	}
	if(form._FROM_.value=="") {
		alert("You forgot to put your name!"); 
		return(false);
	}
	if(form._DESC_.value == "") {
		alert("You forgot to write the description!"); 
		return(false);
	}
	if(wordCount<minWordCount) {
		alert("Your description is only "+wordCount+" word"+(wordCount==1?"":"s")+" long! C'mon, you can do at least "+minWordCount+"!"); 
		return(false);
	}
	if(form._SPAM_CHECK_.value == "") {
		alert("You forgot to enter the phrase proving that you are human and not some SPAM-bot!!"); 
		return(false);
	}
	var spamPhrase = form._SPAM_CHECK_.value.toLowerCase();
	if(spamPhrase.indexOf("i am human") < 0) {
		alert("You incorrectly entered the phrase "+spamPhrase+"to prove that you are human and not some SPAM-bot!!"); 
		return(false);
	}

//	alert("This form has been temporarily disabled!"); return(false);
	return(checkEmail(form._FROM_LINK_.value));
}
