$(document).ready(function() { 
var zaddress = '';	
$('#active_search').css('visibility','hidden');
$('#button').css('visibility','hidden');

$('#address').focus( function() {
	//if($(this).val() == "Street Address, or Intersection" ){
	$(this).val('');
	$(this).css('color', 'black');
	//}
});

$('#city').focus( function() {
	if($(this).val() == "City"){
	$(this).val('');
	$(this).css('color', 'black');
	}else if ($(this).val() == ""){
	$(this).val('');
	$(this).css('color', 'black');
	}
}); 

$('#zip').focus( function() {
	if($(this).val() == "Zip" ){
	$(this).val('');
	$(this).css('color', 'black');
	}else if($(this).val() == "" ){
	$(this).val('');
	$(this).css('color', 'black');
	} 
});

$('#address').change( function() {
zaddress = $(this).val();
});

$('#city').change( function() {
zaddress = zaddress + " " + $(this).val() + " KS";
showAddress(zaddress);
switchVisibility();

});

$('#zip').change( function() {
zaddress = $(this).val();
if (IsNumeric(zaddress)) {
showAddress(zaddress);
switchVisibility();
}

});

$('#miles').change( function() {
	t = $('#miles').val();
	$('#miles2').val(t);
});


});
// Ends document.ready

function IsNumeric(sText) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;   
}
   //These needed to be onChange instead of onClick so it would work in Safari 4 on windows. onClick worked on Safari 3 in windows, and all other browsers.
function switchVisibility () {
	$('#inactive_search').css('visibility','hidden');
	$('#active_search').css('visibility','visible');
	var parms = 'ajax=1';
	$('#level_1').load('mod/get_findType.php', parms, function () {
		$('#findType').change(function () {
			//console.log("clicked findType");
			var parms = 'findType=' + $('#findType').val() + '&ajax=1';
			showButton();
			$('#level_2').load('mod/get_activities.php', parms, function () {
				$('#activity').change(function () {
					var parms = 'findType='+$('#findType').val()+'&activity='+$('#activity').val() + '&ajax=1';
					$('#level_3').load('mod/get_facility.php', parms, function () {
					//console.log("facility parms: " + parms);
						$('#parkSearch').click(function () {
						});//submit
					});//level 3
				
				});//activity change
			});//level 2
		
		});//find type change
	});//level 1

}

function showButton() {
	$('#button').css('visibility','visible');
}