// formReset: confirms that user wishes to reset the content of the form
function formReset(form) {
	var checkReset = confirm("Are you sure you want to reset all information in this form?");
	if (checkReset) {
		form.reset();
	}
}

// SaveAndQuit: used to allow the user to save their current data and quit
function SaveAndQuit(form) {
	form.action += "&method=quit";
	form.submit(); return true;
}

// stringValidate: used to validate user IDs, passwords, and check numbers
function stringValidate(phrase) {
	var valid = /\w/; 		// format for a valid character (only alphanumeric and underscores)
	for (var i = 0; i < phrase.length; i++) {
		if (!valid.exec(phrase.charAt(i))) {
			return false;
		}
	}
	return true;
}

// checkforNumbers: used to check numbers
function checkforNumbers(value) {
	//var valid = /\d/; 		// format for a valid character (numerals only)
	var valid = /[0123456789.]/; 		// format for a valid character (numerals and decimals only)
	for (var i = 0; i < value.length; i++) {
		if (!valid.exec(value.charAt(i))) {
			return false;
		}
	}
	return true;
}

// emailValidate: used to validate email addresses for basic mistakes
function emailValidate(email) {
	var EmailLen = (parseInt(email.length) - 1);
	if (email.indexOf("@") == -1) {								// no "at" symbol
		return false;
	} else if (email.charAt(0) == "@") {						// "at" symbol is first character
		return false;
	} else if (email.charAt(EmailLen) == "@") {					// "at" symbol is last character
		return false;
	} else if (email.indexOf(".") == -1) {						// no periods present
		return false;
	} else if (email.charAt(0) == ".") {						// period is first character
		return false;
	} else if (email.charAt(EmailLen) == ".") {					// period is last character
		return false;
	} else {
		var valid = /\w/;
		for (var i = 0; i < email.length; i++) {
			if (!valid.exec(email.charAt(i)) && (email.charAt(i) != "@") && (email.charAt(i) != ".") && (email.charAt(i) != "-")) {
				return false;									// invalid character(s) found
			}
		}
	}
	// no errors found
	return true;
}
