function validateTextBoxNotBlank (widget, message) {
	if (!/\S/.test(widget.value)) {
		window.alert(message);
		widget.focus();
		widget.select();
		return false;
	}
	return true;
}

function validateRadio (radio, message) {
	/* radio is either a radio button group or a single radio button. */
	/* this way, programs can pass form.something whether it's one radio
	   button or more than one. */
	if (radio.length) {
		for (var i = 0; i < radio.length; ++i) {
			if (radio[i].checked) {
				return true;
			}
		}
		window.alert(message);
		radio[0].focus();
		return false;
	}
	else {
		if (!radio.checked) {
			window.alert(message + " (moo)");
			radio.focus();
			return false;
		}
		return true;
	}
}

/*function validateQuickSearchForm (form) {
	return validateTextBoxNotBlank(form.search,
				       "Please type one or more words " +
				       "into the search box.");
}*/

function validateCompetitiveCrossReferenceForm (form) {
	return validateTextBoxNotBlank(form.search,
				       "Please type one or more words " +
				       "into the search box.");
}

function validateMarketSegmentForm (form) {
	return validateRadio(form.segment,
			     "Please select one of the " +
			     "market segments.");
}

