verifier_champ_text=function(id_champ){
	if($(id_champ)){
    		if($(id_champ).get('value')==''){
    		$(id_champ).set('value',$(id_champ).get('alt'));	
    	}	    	
	} 
}

init_boutons_select=function(e){
	new Event(e).stop();
	var base=this.get('rel');
	//alert("base="+base);
	var parent='detail_'+base+'_txt';

	if($(parent).get('rel')==null){
		$(parent).set('rel',$(parent).get('html'));
	}
	if(this.get('title')=='aucun'){
		$(parent).set('html',$(parent).get('rel'));
	}else{
		$(parent).set('html',$(parent).get('rel')+' > ' +this.get('html'));
	}
	show_select('null');
	var destination='detail_'+base;
	$(destination).set('rel',this.get('title'));
	if($("petiteannonce_liste")){
		rechercher_ajax_annonce();
	}else{
		rechercher_ajax();
	}
	return false;
}

init_resultat_recherche_annonce=function(){
	if($('cache_ajax')){
		$('cache_ajax').fade('0');
	}
    $$(".resultat_recherche_annonce").each(function(resultat) {
		resultat.set('opacity','0.80');
    	resultat.addEvent('mouseover', function(e){
    		resultat.addClass('resultat_hover');
    		resultat.fade('in');
		});
		resultat.addEvent('mouseout', function(e){
			resultat.removeClass('resultat_hover');
			resultat.fade('0.80');
		});
		resultat.addEvent('click', function(e){
			var id_petiteannonce=resultat.getElement('.savoir_plus_petiteannonce').get('alt');
			rechercher_ajax_annonce(id_petiteannonce);
		});
	});
    $$(".savoir_plus_petiteannonce").each(function(lien) {
    	lien.addEvent('click', function(){
    		rechercher_ajax_annonce(lien.get('alt'));
	    	return false;
    	});
    });
    if($('petiteannonce_liste')){
        SexyLightbox = new SexyLightBox({color:'white', dir: racine+'/sexyimages'});
    }

    precharger_images();
   // SexyLightbox='';
   // SexyLightbox = new SexyLightBox({color:'white', dir: racine+'/sexyimages'});
}


function rechercher_ajax_annonce(id_petiteannonce){
	var mot_clef=$('mot_clef').get('value');
	if(mot_clef==$('mot_clef').get('alt')){
		mot_clef='';
	}
	if($('detail_region')){
		var id_region=$('detail_region').get('rel');
		if(id_region==null || id_region=='aucun'){
			id_region='';
		}
	}else{
		id_region='';
	}
	if($('detail_departement')){
		var id_departement=$('detail_departement').get('rel');
		if(id_departement==null || id_departement=='aucun'){
			id_departement='';
		}
	}else{
		id_departement='';
	}
	if($('detail_rubrique')){
		var id_specialite=$('detail_rubrique').get('rel');
		if(id_specialite==null || id_specialite=='aucun'){
			id_specialite='';
		}
	}else{
		id_specialite='';
	}
	
	if(id_petiteannonce==undefined){
		id_petiteannonce='';
	}
	
	//var chaine_requete='mot_clef='+mot_clef+'&id_region='+id_region+'&id_departement='+id_departement+'&id_specialite='+id_specialite+'&id_etablissement='+id_etablissement;				
	var chaine_requete='mot_clef='+mot_clef+'&id_specialite='+id_specialite+'&id_petiteannonce='+id_petiteannonce;
	var req = new Request({
		url:racine+'recherche_annonce.htm',
		method:'post',
		autoCancel:true,
		data:chaine_requete,
		onRequest: function() {
			$('cache_ajax').fade('0.90');
		},
		onSuccess: function(response) {
			var tableau_response=response.split("µ");
			if(tableau_response[1]=='ok'){
				$("petiteannonce_liste").set("html", tableau_response[0]);
				
				if(id_petiteannonce){
					//afficher_masquer_recherche('none');
					 setTimeout(shadow_img2,500);
				}else{
					//afficher_masquer_recherche('block');
				}
				if(tableau_response[2]='detail_dep'){
					if($("liste_departement")){
						$("liste_departement").set("html", tableau_response[3]);
						$$("#liste_departement a").each(function(bt) {
							bt.addEvent('click', init_boutons_select);
						});
					}
				}					
			}else{
				$("petiteannonce_liste").set("html",tableau_response[0]);
			}
			setTimeout(init_resultat_recherche_annonce,500);
			//document.location.replace(url_en_cours+'#mot_clef-'+mot_clef+'-region-'+id_region+'-departement-'+id_departement+'-id_specialite-'+id_specialite+'-id_etablissement-'+id_etablissement);
		}
			
	}).send();
}


