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._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 to prove that you are human and not some SPAM-bot!!"); 
		return(false);
	}

	return(checkEmail(form._FROM_LINK_.value));
}
function displayRow() {
	var i=1, rowNo, obj;
/*
	for(i=6; i<=20; i++) {
		rowNo='row'+((i<10)?'0':'')+i;
		obj=(document.all)?document.all[rowNo]:document.getElementById(rowNo);
		if(obj.style.display=='none') {
			obj.style.display='';
			break;
		} 
	}
	if(i==20) {
		obj=(document.all)?document.all['rowOn']:document.getElementById('rowOn');
		obj.style.display='none';
		obj=(document.all)?document.all['rowOff']:document.getElementById('rowOff');
		obj.style.display='';
	}
*/
	while (obj = document.getElementById('charrow' + (i++)))
	{
		if(obj.style.display=='none') {
			obj.style.display='';
			break;
		} 
	}
	if(!(obj = document.getElementById('charrow' + i)))
	{
		obj=(document.all)?document.all['rowOn']:document.getElementById('rowOn');
		obj.style.display='none';
		obj=(document.all)?document.all['rowOff']:document.getElementById('rowOff');
		obj.style.display='';
	}
	return(false);
}
