function annuaire_importer_mon_profil(url_adresse)
{
	jQuery.ajax({
			type:'GET',
			dataType:'json',
			success:function(data,textStatus)
			{
				var el;
				el=document.getElementById('annuaireproducteur_adr_numero'); el.value=data['numero']; el.focus();
				el=document.getElementById('annuaireproducteur_adr_typevoie');	el.value=data['typevoie']; el.focus();
				el=document.getElementById('annuaireproducteur_adr_nomvoie'); el.value=data['nomvoie']; el.focus();
				el=document.getElementById('annuaireproducteur_adr_complement'); el.value=data['complement']; el.focus();
				el=document.getElementById('annuaireproducteur_adr_cp'); el.value=data['cp']; el.focus();
				el=document.getElementById('annuaireproducteur_adr_ville'); el.value=data['ville']; el.focus();
				el=document.getElementById('annuaireproducteur_adr_pays'); el.value=data['pays']; el.focus();
				el=document.getElementById('annuaireproducteur_societe'); el.value=data['societe']; el.focus();
				el=document.getElementById('annuaireproducteur_siret'); el.value=data['siret']; el.focus();
				el=document.getElementById('annuaireproducteur_groupe'); el.value=data['groupe']; el.focus();
				el=document.getElementById('annuaireproducteur_telephone'); el.value=data['telephone']; el.focus();
				el=document.getElementById('annuaireproducteur_fax'); el.value=data['fax']; el.focus();
				el=document.getElementById('annuaireproducteur_web'); el.value=data['site']; el.focus();
			},
			url:url_adresse
			}); 
}

function setDistance(gdirection)
{
	var distance=gdirection.getDistance();
	var meters=distance['meters'];
	var distance=Math.round(meters/100)/10;
	document.getElementById('distancebox').innerHTML=distance;
}

function annuaireproducteur_drop_marker(latlng,url,message)
{
	if(confirm(message))
	{
		document.getElementById("annuaireproducteur_adr_lat").value=latlng.lat();
		document.getElementById("annuaireproducteur_adr_lng").value=latlng.lng();
		document.getElementById("annuaireproducteur_adr_pertinence").value=99;
		jQuery.ajax({type:'GET', dataType:'json', beforeSend:function()	{ jQuery('#loading_indicator').fadeIn('normal'); },	success:function(data, textStatus)	{},	complete:function()	{ jQuery('#loading_indicator').fadeOut('normal'); }, url:url+"/"+Math.round(latlng.lat()*1000000)+"/"+Math.round(latlng.lng()*1000000) } ); 
	}
	kmap_markers['map_Me'].setLatLng(new GLatLng(document.getElementById("annuaireproducteur_adr_lat").value,document.getElementById("annuaireproducteur_adr_lng").value));
	kmap_maps['map'].setCenter(new google.maps.LatLng( document.getElementById("annuaireproducteur_adr_lat").value, document.getElementById("annuaireproducteur_adr_lng").value));
}

function upload_photo(upload_field)
{
    document.getElementById('upload_verification').style.display = "block";
    document.getElementById('upload_valid').disabled = true;
	document.getElementById("upload_status").src = "/images/loading.gif";
    upload_field.form.submit();
    upload_field.disabled = true;
}

function trash(id,show)
{
	var el=document.getElementById(id);
	if(show)
			el.style.visibility="visible";
	else
			el.style.visibility="hidden";

}

function choix_horaire_change()
{
	var choix_horaire_val=document.getElementById('horaire_choix_horaire').value;
	var choix_horaire_el=document.getElementById('choix_horaire');
	if(choix_horaire_val==3)
	{
		choix_horaire_el.style.display='inline';
		document.getElementById('horaire_heure_debut_hour').value=6;
		document.getElementById('horaire_heure_debut_minute').value=0;
		document.getElementById('horaire_heure_fin_hour').value=22;
		document.getElementById('horaire_heure_fin_minute').value=0;
	}
	else if(choix_horaire_val==2)
	{
		choix_horaire_el.style.display='none';
		document.getElementById('horaire_heure_debut_hour').value=8;
		document.getElementById('horaire_heure_debut_minute').value=0;
		document.getElementById('horaire_heure_fin_hour').value=19;
		document.getElementById('horaire_heure_fin_minute').value=0;
	}
	else if(choix_horaire_val==1)
	{
		choix_horaire_el.style.display='none';
		document.getElementById('horaire_heure_debut_hour').value=14;
		document.getElementById('horaire_heure_debut_minute').value=0;
		document.getElementById('horaire_heure_fin_hour').value=19;
		document.getElementById('horaire_heure_fin_minute').value=0;
	}
	else if(choix_horaire_val==0)
	{
		choix_horaire_el.style.display='none';
		document.getElementById('horaire_heure_debut_hour').value=8;
		document.getElementById('horaire_heure_debut_minute').value=0;
		document.getElementById('horaire_heure_fin_hour').value=12;
		document.getElementById('horaire_heure_fin_minute').value=0;
	}
}

function ajax_rechercher(url,tofind)
{
	jQuery.ajax({
			type:'GET',
			dataType:'html',
			beforeSend:function()
			{
				jQuery('#loading_indicator').fadeIn('normal');
			},
			success:function(data, textStatus)
			{
				jQuery('#AnnuaireProducteur').html(data);
			},
			complete:function()
			{
				jQuery('#loading_indicator').fadeOut('normal');
			},
			url:url+"/"+tofind
			}); 
}
