function getLocationSearchStatus() {
	cityEmpty = (f.city.value =="");
	stateProvinceEmpty = (f.stateProvince.value == "");
	countryEmpty = (f.country.value=="");
	countryUS = (f.country.value=="US");

	if ((!cityEmpty) && (!stateProvinceEmpty) && (!countryEmpty)) { return "COMPLETE_SEARCH"; }
	if ((!stateProvinceEmpty) && (!countryEmpty)) { return "STATE_SEARCH"; }
	if ((!cityEmpty) && (!countryUS) && (!countryEmpty)) { return "NON_US_CITY_SEARCH"; }
	if ((!countryEmpty) && (!countryUS) ) { return "NON_US_COUNTRY_SEARCH"; }
	if ((stateProvinceEmpty) && (countryUS) && (!cityEmpty) ){ return "MISSING_STATE_US_SEARCH"; }
	if ((stateProvinceEmpty) && (countryUS) ){ return "INVALID_US_SEARCH"; }
	if ((!cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "CITY_ONLY"; }
	if ((cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "BLANK"; }
	return "INCOMPLETE";
}

function checkLocationFields() {
	locationStatus = getLocationStatus();

	if (locationStatus =="BLANK") {
		searchForm.addError("~searchCriteriaRequiredError","cityLabel", "stateProvinceError", "countryError" );
		return;
	}
	if (locationStatus == "CITY_ONLY") {
		searchForm.addError("~countryNeededForCitySearchError", "countryError" );
		return;
	}
	if (locationStatus == "INVALID_US_SEARCH") {
		searchForm.addError("~toGeneralUSSearchError","stateProvinceError" );
		return;
	}
}
function getLocationStatus() {
	cityEmpty = (f.city.value =="");
	stateProvinceEmpty = (f.stateProvince.value == "");
	countryEmpty = (f.country.value=="");
	countryUS = (f.country.value=="US");
	
	if ((!cityEmpty) && (!stateProvinceEmpty) && (!countryEmpty)) { return "COMPLETE_SEARCH"; }
	if ((!stateProvinceEmpty) && (!countryEmpty)) { return "STATE_SEARCH"; }
	if ((!cityEmpty) && (!countryUS) && (!countryEmpty)) { return "NON_US_CITY_SEARCH"; }
	if ((!countryEmpty) && (!countryUS) ) { return "NON_US_COUNTRY_SEARCH"; }
	if ((stateProvinceEmpty) && (countryUS) ){ return "INVALID_US_SEARCH"; }
	if ((!cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "CITY_ONLY"; }
	if ((cityEmpty) && (stateProvinceEmpty) && (countryEmpty)) { return "BLANK"; }
	return "INCOMPLETE";
}

function city_onFocus() {
	f.city.value = "";
	if (stateProvinceAutoSet) { f.stateProvince.selectedIndex = 0; }
	if (countryAutoSet) { f.country.selectedIndex = 0; }
}

function city_onBlur() {
	a = isIn(f.city.value.toLowerCase(),topCities)
	if (a != false) {
		setDropDown(a[1],f.stateProvince);
		setDropDown(a[2],f.country);
		//country_onChange();
		stateProvinceAutoSet = true;
		countryAutoSet = true;
	}
}

function stateProvince1_onChange() {
	c = false;
	if(isIn(frmData.stateProvince1.value,us_states)) {
		c = "US";
	} else if(isIn(frmData.stateProvince1.value,ca_prov)) {
		c = "CA";
	} else if(isIn(frmData.stateProvince1.value,misc)) {
		c = "US";
	}
	if (c != false) {
		setDropDown(c,frmData.country1);
	}
	country_onChange();
	stateProvinceAutoSet = false;
}

function stateProvince2_onChange() {
	c = false;
	if(isIn(frmData.stateProvince2.value,us_states)) {
		c = "US";
	} else if(isIn(frmData.stateProvince2.value,ca_prov)) {
		c = "CA";
	} else if(isIn(frmData.stateProvince2.value,misc)) {
		c = "US";
	}
	else
	{
		setDropDown("",frmData.stateProvince2);
	}
	//if (c != false) {
	//	setDropDown(c,frmData.country1);
	//}
	country_onChange();
	stateProvinceAutoSet = false;
}

function country_onChange() {
	if ((frmData.country1[frmData.country1.selectedIndex].value != "US") && (frmData.country1[frmData.country1.selectedIndex].value != "CA")) {
		setDropDown("",frmData.stateProvince1);
	}
	stateProvinceAutoSet = false;
	countryAutoSet = false;
}
