
function loadModels() {
	var maker=$('#maker option:selected').val();
	$.getJSON("/motorradboerse/index/ajaxgetmodels?maker="+maker, showModels);
}

function showModels(data) {

	$("#model option:first").attr("selected", true);	
	$("#model option:first").nextAll().remove(); // alte Options entfernen (ausser die 1.)
	
	$.each(data, function(val, text) {
	    $('#model').append(
	        $('<option></option>').val(val).html(text)
	    );
	});
}

function countResults() {
	var args = $("#form").serialize();
	$.get("/motorradboerse/index/ajaxcountresults?"+args, showResultCount);
}

function showResultCount(count) {
	if (count==0) {
		$('#search').val("Keine Ergebnisse").attr("disabled", "disabled");
	} else {
		$('#search').val(count + " anzeigen").attr("disabled", "");
	}
}