$(document).ready(function(){
	disableUmkreis();	
	/*plz ort*/
	$('#sPlzOrt').bind('focus blur',function(e){
		this.value = $.trim(this.value);
		geoid = $('#geoid').val();
		
		disableUmkreis();
		
	});	
	
	function disableUmkreis(){		
		if($('#sPlzOrt').val().length == 0 || geoid.split('#')[0] == 'BUN'){
			$('#sUmkreis').attr('disabled','disabled');
		}else{
			$('#sUmkreis').attr('disabled','');
		}		
	}
	
	$("#sPlzOrt, #dSIplzOrt").change(function(){
		$("input[id*='geoid']").val('');
	});
	
	/*PLZ ORT BUNDESLAND*/
	$("#sPlzOrt").autocomplete("http://"+window.location.hostname+"/ajax_php/suche_get_ortschaften.php",{ 
			inputClass:"slform",resultsClass:"ac_results",lineSeparator:"\n",cellSeparator:"|",minChars:2,
			delay:500,matchCase:0,matchSubset:true,matchContains:0,cacheLength:10,mustMatch:false,extraParams:{},
			loadingClass:"ac_loading",selectFirst:true,selectOnly:true,autoFill:false,width:250,scroll:true,
			scrollHeight:200
	});
		
	$("#sPlzOrt").result(function(event, data, formatted) {
		if (data)
			$("input[id*='geoid']").val(data[1]);
	});
	
});




