	//===============================================
	//==== Variables used in form check routines ====
	//===============================================
	var whitespace = " \t\n\r";
	//================================================================================
	//=== Remove whitespace characters and check whether remaining string is empty ===
	//=== If string null or empty return false; else if non-whitespace character   ===
	//=== return true; else no non-whitespace characters found - return false      ===
	//================================================================================
	function isStringFilled(s) {
	var i;
		if ((s == null) || (s.length == 0)) return false;
		for (i = 0; i < s.length; i++) {
			var c = s.charAt(i);
			if (whitespace.indexOf(c) == -1) return true;			
		}
		return false;
	}
	
	//====================================
	//=== Is entry a positive integer? ===
	//====================================
	function isPosInteger (n) {
		if (!isStringFilled(n)) return false;
		for (var i = 0; i < n.length; i++) {
			if (n.charAt(i) < "0" || n.charAt(i) > "9") return false;
		}
		return true;
	}
	
	//=====================================
	//=== Is entry a valid US zip code? ===
	//=====================================
	function isUSZipCode(s) {
		var front, sep, back;
		switch(s.length) {
			case 5:
			case 9:
				return isPosInteger(s);
				break;
			case 10:
				front = isPosInteger(s.substring(0,5));
				sep = (s.substring(5,6) == "-");
				back = isPosInteger(s.substring(6,10));
				return (front && sep && back);			
			default:
				return false;
		}
		return true;
	}
	
	function checkCityState(f) {
		if (!isStringFilled(f.city.value)) {
			alert("Please enter a city or town for this search.");
			f.city.focus();
			return false;
		}
		if (f.state.selectedIndex == 0) {
		   alert("Please select a state.");
		   f.state.focus();
		   return false;
		}
	return true;
	}
	
	function checkFindStore(f) {
		if (!isUSZipCode(f.zip.value)) {
			alert("Please enter a US zip code.");
			f.zip.focus();
			return false;
		}
		if (!isPosInteger(f.distance.value)) {
			alert("Please enter a distance in miles.");
			f.distance.focus();
			return false;
		}
		var dist = f.distance.value;
		if (dist < 1) {
			alert("Please enter a distance of at least 1 mile.");
			f.distance.focus();
			return false;
		}
		document.getElementById("locate-1").style.display = "block";
		f.submit();
	}
