function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }



function verifySearch() {
	var city = document.getElementById('city').value;
	var zipcode = document.getElementById('zipcode').value;
	
	if (document.getElementById('city').value == "Enter a City" && document.getElementById('zipcode').value == "Enter a Zipcode" ) {
		alert("Please enter a city or a zipcode before searching.");
		return;
	}

	if (document.getElementById('city').value == "Enter a City") {
		city = "";
	}
	else if (document.getElementById('zipcode').value == "Enter a Zipcode") {
		zipcode = "";
	}
	document.theform.zipcode.value = zipcode;
	document.theform.city.value = city;

	minprice = document.getElementById('minprice').value;
	maxprice = document.getElementById('maxprice').value;
	document.theform.minprice.value = minprice.replace(/[$,]/g,"");
	document.theform.maxprice.value = maxprice.replace(/[$,]/g,"");

	document.theform.submit();
}


function submitMap() {
	var cityzip = document.getElementById('cityzip').value;
	
	if (document.getElementById('cityzip').value == "Enter a City or Zip Code") {
		alert("Please enter a city or zip code before searching.");
		return;
	}
	else if (IsNumeric(cityzip) == false) {
		document.theform.city.value = cityzip;
		document.theform.zipcode.value = "";
		document.theform.search_type.value = "city";
		document.theform.display_style.value = "map";
		document.theform.submit();
	}
	else {
		document.theform.zipcode.value = cityzip;
		document.theform.city.value = "";
		document.theform.search_type.value = "zipcode";
		document.theform.display_style.value = "map";
		document.theform.submit();
	}
}

function submitPerimeter() {
	var cityzip = document.getElementById('cityzip').value;
	
	if (document.getElementById('cityzip').value == "Enter a City or Zip Code") {
		alert("Please enter a city or zip code before searching.");
		return;
	}
	else if (IsNumeric(cityzip) == false) {
		document.theform.city.value = cityzip;
		document.theform.zipcode.value = "";
		document.theform.search_type.value = "city";
		document.theform.display_style.value = "summary";
		document.theform.submit();
	}
	else {
		document.theform.zipcode.value = cityzip;
		document.theform.city.value = "";
		document.theform.search_type.value = "zipcode";
		document.theform.display_style.value = "summary";
		document.theform.submit();
	}
}


