/*
function to validate the story submission form input, if each field validates correctly the form will submit. If there is an error, 
the error array will be added to and the form will not submit. The errors for the appropriate fields will display instead
*/
function storyValidate(){
	//first establish all the variables
	var titleField, txtField, allow;
	//turn the errors variable into a new array with a length of 5
	var errors = new Array(2);
	//assign the values to each variable corresponding to the appropriate field
	titleField = document.storyForm.title.value;
	txtField = document.storyForm.txt.value;
	
	//validate the name field first
	//first check to make sure the field is not empty
		

	//validate the title field
	//make sure the field is not empty.
	if(titleField == ''){
		document.getElementById('titleError').style.display = "block";
		errors[0] = 'yes';
	}else{
		document.getElementById('titleError').style.display = "none";
		errors[0] = '';
	}

	//validate the txt field
	//make sure the field is not empty.
	if(txtField == ''){
		document.getElementById('storyError').style.display = "block";
		errors[1] = 'yes';
	}else{
		if(txtField.length < 350){
			document.getElementById('storyError').style.display = "block";
			errors[1] = 'yes';
		}else{
			document.getElementById('storyError').style.display = "none";
			errors[1] = '';
		}
	}


	//check the errors array
	for(i=0; i<2; i++){
		if(errors[i] == 'yes'){
			allow = 'no';
		}
	}
	
	//check the allow flag. This flag determines whether or not to submit the information
	if(allow == 'no'){
		return false;

	}else{
		return true;
	}

}