var motrechertemp='';
var optiontemp='';

function actu_bloc(limit){
	$.post("modules/ajax_bloc_actu.php", { limit: limit },
	  function(data){
		document.getElementById('actu_bloc_ajax').innerHTML=data;		
	  });
}

function offres_speciale_mail(email){
	$.post("modules/ajax_offres_speciales.php", { email: email },
	  function(data){
		  if(data!='vide'){
			var tbl_off_spe_mail=data.split('|');
			document.getElementById('nom').value=tbl_off_spe_mail[0];
			document.getElementById('prenom').value=tbl_off_spe_mail[1];
			document.getElementById('cp').value=tbl_off_spe_mail[2];
		  }
	  });
}

function devis_ajout_ref(ref,div){
	$.post("modules/ajax_devis_ajout_ref.php", { ref: ref, div:div },
	  function(data){
		  if(data!='vide'){
			var tblretour=data.split('|');			
			document.getElementById(tblretour[0]).innerHTML=tblretour[1];  
		  }
	  });
}

function devis_identitee_mail(email){
	$.post("modules/ajax_devis_identitee.php", { email: email },
	  function(data){
		  if(data!='vide'){
			var tbl_devis_identitee_mail=data.split('|');
			document.getElementById('nom').value=tbl_devis_identitee_mail[0];
			document.getElementById('prenom').value=tbl_devis_identitee_mail[1];
			document.getElementById('adresse').value=tbl_devis_identitee_mail[2];
			document.getElementById('cp').value=tbl_devis_identitee_mail[3];
			document.getElementById('ville').value=tbl_devis_identitee_mail[4];
			document.getElementById('tel').value=tbl_devis_identitee_mail[5];
		  }
	  
	  });
}
function recherche_distrib(type,thiss){
	if(thiss.value.length>=2){
		var nom='';
		var dep='';
		if(type=='nom'){
			nom=thiss.value;
			document.getElementById('dep').value='';
		}else{ 
			dep=thiss.value;
			document.getElementById('nom_distrib').value='';
		}
		if(motrechertemp!=nom+dep)
		{
			motrechertemp=nom+dep;
			$.post("modules/ajax_distributeur.php", { nom: nom, dep: dep },
			  function(data){
				document.getElementById('retour_ajax').innerHTML=data;
				
			  });
		}
	}
}

function recherche_piece(thiss){ 
	var recherche='';
	var option='';
	recherche=document.getElementById('recherche_input').value;
	if( document.getElementById('reference').checked ==true )
		option='R';
	if( document.getElementById('designation').checked ==true )
		option=option+'D';
		
	if(recherche.length>=2 && option!=''){		
		if(motrechertemp!=recherche || option!=optiontemp)
		{
			motrechertemp=recherche;
			optiontemp=option;
			$.post("modules/ajax_piece.php", { recherche: recherche,option:option },
			  function(data){
				document.getElementById('retour_ajax').innerHTML=data;
				
			  });
		}
	}
}