/* 2.19.2004 Kerry Colligan
	this is the javascript that checks for mandatory fields on the contact form
	it returns a pop-up window showing fields that require additional information
	for it to work properly, the contact form must call "verify(this)" in an onSubmit
	paramter of the form tag
	
	the form can contain a string of this.fieldname.optional=true; statements before the 
	verify(this) call. fields noted as such will not be required
	*/
	
function isBlank(s) {
	for(var i=0; i<s.length; i++){
		var c=s.charAt(i);
		if((c != ' ') && (c != '\n') && (c!= '\t')) return false;
		}
	return true;
	}
function verify(f){
	var msg;
	var empty_fields ="";
	var errors="";
	for(var i=0; i<f.length; i++){
		var e=f.elements[i];
		if(((e.type=="text") || (e.type=="textarea") || (e.type=="password")) && !e.optional){
			if((e.value==null) || (e.value=="") || isBlank(e.value)){
				empty_fields += "\n	" + e.name;
				continue;
				}
			}
		}

	if(!empty_fields && !errors) return true;
	msg = "---------------------------------------------------------------------------\n\n";
	msg += "The form was not submitted because of the following error(s).\n";
	msg += "Please correct these error(s) and re-submit.\n";
	msg += "--------------------------------------------------------------------------\n\n";
	if(empty_fields){
		var re = new RegExp ('_', 'gi') ;
		var newstr = empty_fields.replace(re, ' ') ;

		msg += "- The following required field(s) are empty:" + newstr + "\n";
		if(errors) msg += "\n";
		}
	msg += errors;
	alert(msg);
	return false;
	}