// JavaScript Document

$(document).ready(function() {
	init_loader();
});

function init_loader() {
	$("input[id^=animal_]").each( function() {
		$(this).click( function() { 
				load_races($(this).val());
		});
	});
	doAutocomplete();
}

function animload() {
	$("#searchform_content").html("<img src='/images/loadingAnimation.gif'>");
}

function load_races(animal) {
	
	$.getJSON("/annuaire/getAjaxRaces", {animal: animal},
		function(data) {
			$("#search_races").removeOption(/./);
			
			$("#search_races").addOption(data, false);
		});
	
	$("#search_races").selectOptions("all", true);
	
};

function relocateMap(lat, lng, marker_id, addr) {
	var marker = eval(marker_id);
    map.setCenter(new google.maps.LatLng(lat, lng), 16);
	marker.openInfoWindowHtml(addr);
};


function doAutocomplete() {
	
var url = "/annuaire/getAjaxCity";
	
	$("#directory_search_location").autocomplete(url, {
	minChars: 2,
    extraParams: {
       country: function() { return $("#country").val(); }
    }
	
});
};
