//<![CDATA[
	window.onload = function () {
		//$("search").focusFirstElement();
		Event.observe("country", "change", function(event) { loadCity(); });
		var city = getUrlParameter("city");
		if (city) loadCity();
	}
	var loaded = false;
	Ajax.Responders.register({
		onCreate: function() {
			loaded = false;
			//Retrasamos la salida del mensaje de carga para evitar que aparezca en caso de que la carga sea casi inmediata.
			window.setTimeout(function() {
				if ($("loading") && !loaded) {
					$("response").hide();
					$("loading").show();
				}
			}, 1000);
		},
		onComplete: function() {
			$("response").show();		 
			$("loading").hide();
			
			var city = getUrlParameter("city");
			if (city) $("city").value = city;
			
			loaded = true;
		}
	});
	function loadCity() {
		var ajx = new Ajax.Updater("responsecity",	"../search/select-cities.php", {
			parameters: "country=" + $("country").value,
			requestHeaders: { "X-Referer": document.location } //Servirá para reescribir la URL en la paginación del listado. 
		});
	}
	function search() {
		with (document.search) {
			action = "../search/";
			submit();
		}
	}
	function reset() {
		with (document.search) {
			country.value = '0';
			city.value = '0';
			loadCity();
			type.value = '0';
			name.value = '';
			country.focus();
		}
	}
	//]]>
