// Copyright Scott R. Moore 2002, All Rights Reserved

// FUNCTION: formCheck('thisForm' HTML form object)
// Check to make that something was entered for name, and that at least one
// of the email or phone fields is filled out
// Eventually this will be where to check email and phone number validity
function formCheck(thisForm) {
	var name = new String(thisForm.name);
	var email = new String(thisForm.email);
	var phone = new String(thisForm.phone);
	
	if ( (name.length() == 0) || ( (email.length() == 0) && (phone.length() == 0) ) ) {
		var alertmsg = "Something is missing in the following fields:\n\n";
		if (name.length() == 0) {
			alertmsg += "\t--Name";
		}
		if ( (email.length() == 0) && (phone.length() == 0) ) {
			alertmsg += "\t--Email address OR phone number";
		}
		alert(alertmsg);
	} else {
		thisForm.submit();
	}
	return true;
}

// FUNCTION: formElementCheck(
//		'element'		string submitted by element
//		'element_type'	type of element (phone number, email, etc) 
//		'def_string'	the default string contained by this element
//		'err_msg'		default error message to return if check fails
// )
// Checks the element to see if it is empty, or if it contains the 
// default string.  If so, it returns the default error message.
// Eventually, this will check for valid element types (email, phone #, etc).
function formElementCheck(element, element_type, def_string, err_msg) {
	var checkElement = new String(element);
	if ( (checkElement.indexOf(def_string) > -1) || (checkElement.length == 0) ) {
		return err_msg;
	}
	return "";
}

// Copyright Scott R. Moore 2002, All Rights Reserved

