/*=============================================================================
   general.js
   ----------
   Similar to the general.inc.php file. Functions defined within here are
   generally useful across the entire project.
   
   Requires: prototype.js
==============================================================================*/

/*
	This function checks a text field to make sure it's not Null or empty.
	NOTE: Requires prototype.js to be included.
*/
function check_txtfield_presence(form_field) {
	if (!form_field.value || form_field.value.strip() == "") {
		return false;
	}
	return true;
} // check_txtfield_presence()

/*
	This function checks a variable to make sure it's not Null or empty.
*/
function check_txtvar_presence(txtvar) {
	if (!txtvar || txtvar.strip() == "") {
		return false;
	}
	return true;
} // check_txtvar_presence()

/* 
	Prompt with a message, loop if they enter nothing. On Cancel, break out. 
*/
function prompt_and_handle_cancel(prompt_txt) {
	var results = prompt(prompt_txt);
		
	// If they just hit enter through the prompt, show it again.
	if (results.strip() == "") {
		results = prompt_and_handle_cancel(prompt_txt);
	} else if (!check_txtvar_presence(results)) {
		return null;
	}
	// If it gets this far, we're done.
	return results;
} // end prompt_and_handle_cancel()