//Form Validation
//"Notice" Text Submission
//Version 1.0  01/29/03
//D. Jean Hester

function validate() {
	//alert("in validate");
	var msg =""; //variable for error msg
	var text_valid = "true"; //variable for no blank required fields
	var max_length = 500; //variable for allowed length of text fields
	var text_length_valid = "true"; //variable for text fields of correct length
	
	//test for at least one text box being filled in
	if ( (document.notice_text.text_01.value == "") && (document.notice_text.text_02.value == "") && 
		 (document.notice_text.text_03.value == "") ) {		
		text_valid = "false";
		//alert("text_valid is" + text_valid);
	} else {
		//alert("text_valid is" + text_valid);
		//alert ("boxes filled in.");
	}
	
	//test for length of text boxes
	if ( (document.notice_text.text_01.value.length > max_length) || (document.notice_text.text_02.value.length > max_length) ||
		(document.notice_text.text_03.value.length > max_length) )  {
		text_length_valid = "false";
		//alert("text length valid is " + text_length_valid);
		//alert("lenght of box 1= " + document.notice_text.text_01.value.length);
		//alert("lenght of box 2= " + document.notice_text.text_02.value.length);
		//alert("lenght of box 3= " + document.notice_text.text_03.value.length);
	} else {
		//alert ("text lengths are all ok");
	}
	
	//now see if any of the test conditions failed
	if ( (text_valid == "false") || (text_length_valid == "false") ){
		//alert("in test loop for false");
		msg = "The form was not submitted due to the following error: \n";
		if (text_valid == "false") {
		msg += "You need to enter text into at least one of the three text boxes.  Tell me what you noticed.";
		} else {
		msg += "The text you entered is too long.  Keep it under 500 characters, ok?";
		}
		alert(msg);
		return false;
	} else {
		//return true;
	}
		
}

