function findChattyWords(text) {

forbiddenWords = new RegExp("( btw )", "i");

if (text.match(forbiddenWords)) {
	alert("Please don't use TXT talk in a written story such as '" + RegExp.$1 + "'");
	return true;
}
else {
	return false;
}
}

function validate(theform) {
if (theform.thename) var thename=theform.thename.value;
if (theform.email) var email=theform.email.value;
var country = theform.country.options[theform.country.options.selectedIndex].value;
var us_states = theform.us_states.options[theform.us_states.options.selectedIndex].value;
var storytitle = theform.storytitle.value;
var story = theform.story.value;
var about_users_comments = theform.about_users_comments.options[theform.about_users_comments.options.selectedIndex].value;
if (theform.terms) var terms=theform.terms;

username_illegal_chars = new RegExp("[^ \.A-Za-z0-9-]");
title_illegal_chars = new RegExp("[^ \.\'\:\?\,A-Za-z0-9-]");
find_commas = new RegExp(",");

if (findLeetSpeak(story)) return false;
if (findCurseWords(story)) return false;
if (findTextAbuse(story)) return false;
if (findChattyWords(story)) return false;

if (theform.thename) {
	
	if (thename == "") {
	alert("Please insert your name");
	theform.thename.focus();
	return false;
	}
	else if (username_illegal_chars.test(thename)) {
	alert(thename.match(username_illegal_chars) + " is an illegal character in a name. You can only use alphanumerical characters, spaces, point, dash.");
	theform.thename.focus();
	return false;
	}
}
if ((theform.email) && (email == "")) {
	alert("You forgot to insert your email address");
	theform.email.focus();
	return false;
}
else if (country == "select") {
	alert("You forgot to select your country");
	theform.country.focus();
	return false;
}
else if ((country == "US") && (us_states == "select")) {
	alert("You forgot to select your state");
	theform.us_states.focus();
	return false;
}
else if (storytitle=="") {
	alert("You forgot to insert a title");
	theform.storytitle.focus();
	return false;
}
else if (title_illegal_chars.test(storytitle)) {
	alert("The character '" + storytitle.match(title_illegal_chars) + "' is not permitted in a title");
	theform.storytitle.focus();
	return false;
}
else if (storytitle.length > 60) {
	alert("Your title has " + storytitle.length + " characters, the maximum is 60.\nPlease shorten it a bit.");
	theform.storytitle.focus();
	return false;
}
else if (storytitle.charAt(storytitle.length - 1) == ".") {
	alert("Titles shouldn't end with a period. Please remove it.");
	theform.storytitle.focus();
	return false;
}
else if (story.length < 1200) {
	alert("Your story has " + story.length + " characters, the minimum is 1200.\nPlease provide more details or develop it a bit more.\nStories stuffed with repetitive characters, spaces or punctuations to avoid this message will be discarded.");
	theform.story.focus();
	return false;
}
else if (story == story.toUpperCase()) { //avoiding all upper case posts

	alert("Please don't write stories in all uppercase");
	theform.story.focus();
	return false;
	
}
else if ((story.charAt(0).toUpperCase() == "O") && (story.charAt(1).toUpperCase() == "K")) { //stories that start with OK

	alert("Please don't start a story with \"OK\",\nit's not needed, just get right to the story.");
	theform.story.focus();
	return false;
}
else if ((story.charAt(0).toUpperCase() == "H") && (story.charAt(1).toUpperCase() == "I")) { //stories that start with HI

	alert("Please don't start a story with \"HI\",\nit's not needed, just get right to the story.");
	theform.story.focus();
	return false;
}
else if ((story.charAt(0).toUpperCase() == "H") && (story.charAt(1).toUpperCase() == "E") && (story.charAt(2).toUpperCase() == "L") && (story.charAt(3).toUpperCase() == "L") && (story.charAt(4).toUpperCase() == "O")) { //stories that start with HI

	alert("Please don't start a story with \"HELLO\",\nit's not needed, just get right to the story.");
	theform.story.focus();
	return false;
}
else if ((story.charAt(0).toUpperCase() == "W") && (story.charAt(1).toUpperCase() == "E") && (story.charAt(2).toUpperCase() == "L") && (story.charAt(3).toUpperCase() == "L")) { //stories that start with WELL

	alert("Please don't start a story with \"WELL\",\nit's not needed, just get right to the story.");
	theform.story.focus();
	return false;
}
else if (!story.match(find_commas)) { //stories with no commas

	alert("Please use commas in your story.\nStories with no punctuation will be discarded.");
	theform.story.focus();
	return false;
}

else if (about_users_comments == "select") {
	alert("You forgot to indicate your expectations toward users comments");
	theform.about_users_comments.focus();
	return false;
}

else if ((terms) && (terms.checked == false)) {
	alert("You must read and agree to our terms and conditions before submitting your story");
	theform.terms.focus();
	return false;
}

if (theform.email) {
	if (verifyEmail(email)) return true;
}
else return true;
}

// character counter

function countcharacters(form) {
	
form.charcounter.value = (form.story.value).length;
	
}