$(function() {
	$('#plz').keyup(function() {	
        var plz = $(this).val();
		var ort = $('#ort').val();
		$('#ort').css({background: "#fff"});

		if ( plz.length == 5 ) {
			// --- AJAX-ABFRAGE  ---
			$.ajax({
				url: './includes/auto_plz/autoplz.php?plz=' + plz,
				cache: false,
				success: function(html) {
					if ( html ) {
						$('#ort').val(html);
						$('#ort').css({background: "#0f0"});
					}						
				}	
			});
			// --- /AJAX-ABFRAGE ---
		} else {
            $('#ort').val('');
		}
	});
	
	$('#plz2').keyup(function() {	
        var plz2 = $(this).val();
		var ort2 = $('#ort2').val();
		$('#ort2').css({background: "#fff"});

		if ( plz2.length == 5 ) {
			// --- AJAX-ABFRAGE  ---
			$.ajax({
				url: './includes/auto_plz/autoplz.php?plz=' + plz2,
				cache: false,
				success: function(html) {
					if ( html ) {
						$('#ort2').val(html);
						$('#ort2').css({background: "#0f0"});
					}						
				}	
			});
			// --- /AJAX-ABFRAGE ---
		} else {
            $('#ort2').val('');
		}
	});
	
	$('#ort2').keyup(function() {
		$('#ort2').css({background: "#fff"});
	});
});
