function checkWordLen(){
	var obj = document.getElementById('essayPoem');
	var wordLen = 1000;
	var len = obj.value.split(/[\s]+/);
	console.log(len.length);
	document.getElementById('wordCount').innerHTML = 1000 - len.length;
	if(len.length > wordLen){
		alert("Your essay/poem can't be longer than 1,000 words.");
		obj.oldValue = obj.value!=obj.oldValue?obj.value:obj.oldValue;
		obj.value = obj.oldValue?obj.oldValue:"";
	return false;
	}
	return true;
}

function spaceCheck(e){
	var obj = document.getElementById('essayPoem');
	var wordLen = 1000;
	var len = obj.value.split(/[\s]+/);
	document.getElementById('wordCount').innerHTML = 1000 - len.length;
	/*var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	var character = String.fromCharCode(code);
	if(character==" ")
		checkWordLen();*/
}

function validateEssay(thisForm){
	var found_notify = "nothing";
	with(thisForm){
		if (ident.value == null || ident.value == ""){
			alert("Please enter your name");
			return false;
		}
		if (email.value == null || email.value == ""){
			alert("Please enter your email address");
			return false;
		}
		if (address.value == null || address.value == ""){
			alert("Please enter your street address");
			return false;
		}
		if (city.value == null || city.value == ""){
			alert("Please enter your city");
			return false;
		}
		if (zip.value == null || zip.value == ""){
			alert("Please enter your zip code");
			return false;
		}
		if (phone.value == null || phone.value == ""){
			alert("Please enter your phone number");
			return false;
		}
		if (school.value == null || school.value == ""){
			alert("Please enter the name of your school");
			return false;
		}
		for (var i=0; i<notify.length; i++)  { 
			if (notify[i].checked)  {
				found_notify = notify[i].value //set found_it equal to checked button's value

			} 
		}
		if (found_notify == "nothing"){
			alert("Please select how you would like to be contacted");
			return false;
		}
		if (title.value == null || title.value == ""){
			alert("Please enter a title");
			return false;
		}
		if (essayPoem.value == null || essayPoem.value == ""){
			alert("Please enter your essay or poem");
			return false;
		}
		if (document.getElementById('wordCount').innerHTML < 0){
			alert("Please adjust your essay/poem to not exceed the 1000 word limit");
			return false;
		}
		return true;
	}
}
