

  function loadData(post){	
 

		$('#typ').empty();
		$('#vil').empty();
		$('#quart').empty();
		$('#prix').empty();
		
		
	
	
		if ($(":checked").val() =="VENTE") {
			  $("form").attr("action", "immobilier-rennes-le-rheu-melesse-vente-location-recherche-vente");

			file = 'formVente_json.php' 
		
	
		}else{
			
			file = 'formloc_json.php';
	  $("form").attr("action", "immobilier-à-rennes-le_Rheu-Melesse-vente-Location-recherche-location");
			
		}
		
	
		var jqxhr=$.getJSON(file,post, function(data) {

	
			if (data.req['p'] == "1") {
		
		selPrix ='<option value="0"';
		selPrix += (data.req['prix'] == "0") ? ' selected="selected" ': ' ';
		selPrix += '>Prix (tous) </option> <option value="1"';
		selPrix += (data.req['prix'] == "1") ? ' selected="selected" ': '' ;
		selPrix += ' >moins de 100000 euros</option><option value="2"';
		selPrix +=(data.req['prix'] == "2") ?	' selected="selected" ':'' ;
		selPrix += '>de 100 000 à 200 000€</option><option value="3"';
		selPrix +=(data.req['prix'] == "3") ? ' selected="selected" ':'' ;
		selPrix +='>de 200 000 à 400 000€</option> <option value="4"';
		selPrix +=(data.req['prix'] == "4") ?	' selected="selected" ':'' ;
		selPrix += '>plus de 400 000€</option>';
		}else{
				
			selPrix ='<option value="0"';
		selPrix += (data.req['prix'] == "0") ? ' selected="selected" ': ' ';
		selPrix += '>Prix (tous) </option> <option value="1"';
		selPrix += (data.req['prix'] == "1") ? ' selected="selected" ': '' ;
		selPrix += ' >moins de 300€</option><option value="2"';
		selPrix +=(data.req['prix'] == "2") ?	' selected="selected" ':'' ;
		selPrix += '>de 300€ à 500€</option><option value="3"';
		selPrix +=(data.req['prix'] == "3") ? ' selected="selected" ':'' ;
		selPrix +='>de 500€ à 700€</option> <option value="4"';
		selPrix +=(data.req['prix'] == "4") ?	' selected="selected" ':'' ;
		selPrix += '>plus de 700€</option>';		
	
			
		}
		
		
		$('#prix').append(selPrix);  
		var itemsquart= [];
		itemsquart.push('<option value="tous">Quartiers(tous)</option>');	
		var itemstypes= [];
	itemstypes.push('<option value="tous">Type de logement(tous)</option>');
		
		var itemsvilles= [];
	itemsvilles.push('<option value="tous" selected="selected">localisation(tous)</option>');

		  
		    $.each(data.villes, function(key, val) {
			v=(data.req['ville'] == key) ? ' selected="selected" ' : '';
			vv=(val == 0) ? '<option  style="text-indent:5px;" value="'+key+'"'+v+'>'+key+'</option>':'<option style="font-weight:bold" value="'+key+'"'+v+'>'+key+'<span>('+val+')</span>'+'</option>';
			itemsvilles.push(vv);
	
		  });	
		  
		
			var htmlv=itemsvilles.join('');
			$('#vil').append(htmlv);
	
		  
		    $.each(data.type, function(key, val) {
			
			typ=(data.req['type'] == key) ? ' selected="selected" ' : '';
			vt=(val == 0) ? '<option  style="text-indent:5px;" value="'+key+'"'+typ+'>'+key+'</option>':'<option style="font-weight:bold" value="'+key+'"'+typ+'>'+key+'('+val+')'+'</option>';
			itemstypes.push(vt);
			
			
	
		  });
		  
			
			var htmlt=itemstypes.join('')
	$('#typ').append(htmlt);
		  
		
	if (data.req['ville'] =="RENNES"){	  
		      $.each(data.quartier, function(key, val) {
			
			vqq=(data.req['quart'] == key) ? ' selected="selected" ' : '';
			vq=(val == 0) ? '<option  style="text-indent:5px;" value="'+key+'"'+vqq+'>'+key+'</option>':'<option style="font-weight:bold" value="'+key+'"'+vqq+'>'+key+'('+val+')'+'</option>';
			itemsquart.push(vq);
	
		  });	
		  
		 $('<select/>', {
			id:"quart",
			name:"quart",
			'class':"sel",
			html: itemsquart.join('')
		  }).appendTo('#quart');
	}
		  
		  
		  
		  $("#ref").is(function(){
		  	 $("#ref").focus().autocomplete(data.ref).flushCache();
		});
		  
		  
		  
	});
		
		
	
	
		
}
