function Plustard(variable) {
	
	jQuery.post("ajax/_maj_plustard.php", {variable: ""+variable+""}, function(data){
			if(data.length >0) {
				
				jQuery('#AffBtn').show();
				jQuery('#AffBtn').html(data);
			}
			
		});
	
} // lookup
function MaJDpt(region) {
	
	jQuery.post("ajax/_maj_dpt.php", {region: ""+region+""}, function(data){
			if(data.length >0) {
				
				jQuery('#AffDpt').show();
				jQuery('#AffDpt').html(data);
			}
			
		});
	
} // lookup

function MaJSsCat(cat) {
	
	if(cat.length == 0) {
		// Hide the suggestion box.
		jQuery('#AffSsCat').hide();
	} else {
		jQuery.post("ajax/MaJSsCat.php", {cat: ""+cat+""}, function(data){
			if(data.length >0) {
				jQuery('#AffSsCat').show();
				jQuery('#AffSsCat').html(data);
			}
			
		});
	}
} // lookup



function MaJType(cat) {
	
	if(cat.length == 0) {
		// Hide the suggestion box.
		jQuery('#AffType').hide();
	} else {
		jQuery.post("ajax/MaJType.php", {cat: ""+cat+""}, function(data){
			if(data.length >0) {
				jQuery('#AffType').show();
				jQuery('#AffType').html(data);
			}
			
		});
	}
} // lookup



function MaJSsType(sscat) {
	
	if(sscat.length == 0) {
		// Hide the suggestion box.
		jQuery('#AffType').hide();
	} else {
		jQuery.post("ajax/MaJType.php", {sscat: ""+sscat+""}, function(data){
			if(data.length >0) {
				jQuery('#AffType').show();
				jQuery('#AffType').html(data);
			}
			
		});
	}
} // lookup

function MaJDpt(region) {
	
	 
		jQuery.post("ajax/_maj_dpt.php", {region: ""+region+""}, function(data){
			if(data.length >0) {
				
				jQuery('#AffDpt').show();
				jQuery('#AffDpt').html(data);
			}
			
		});
	
} // lookup

function AjoutObjet(valeur){
	
		jQuery.post("ajax/MaJAjoutObjet.php", {motcle: ""+valeur+""}, function(data){
			if(data.length >0) {
				jQuery('#AffAjoutObjet').show();
				jQuery('#AffAjoutObjet').html(data);
			}
			
		});
	
}

function SupObjet(valeur){
	if( valeur.length == 0 ) {
		// Hide the suggestion box.
		jQuery('#AffAjoutObjet').hide();
	} else {
		jQuery.post("ajax/MaJSupObjet.php", {id: ""+valeur+""}, function(data){
			if(data.length >0) {
				jQuery('#AffAjoutObjet').show();
				jQuery('#AffAjoutObjet').html(data);
			}
			
		});
	}
}

function AjoutObjet2(valeur){
	
		jQuery.post("ajax/MaJAjoutObjet2.php", {motcle: ""+valeur+""}, function(data){
			if(data.length >0) {
				jQuery('#AffListeObjet').show();
				jQuery('#AffListeObjet').html(data);
			}
			
		});
}

function SupObjet2(valeur){
	if( valeur.length == 0 ) {
		// Hide the suggestion box.
		jQuery('#AffListeObjet').hide();
	} else {
		jQuery.post("ajax/MaJSupObjet2.php", {id: ""+valeur+""}, function(data){
			if(data.length >0) {
				jQuery('#AffListeObjet').show();
				jQuery('#AffListeObjet').html(data);
			}
			
		});
	}
}

function MasqueDiv(div){
	document.getElementById(div).style.display='none';
}

function MontreDiv(div){
	document.getElementById(div).style.display='block';
}

function AfficheDiv(div,div2,div3){
	
	if( (document.getElementById(div2).innerHTML != '') ||  (document.getElementById(div3).innerHTML != '') ){ // On a déjà cliqué 1 fois
		if(document.getElementById(div3).innerHTML != ''){
			document.getElementById(div2).innerHTML = document.getElementById(div3).innerHTML;
		}
		document.getElementById(div3).innerHTML = '';
	}
	else{
		document.getElementById(div2).innerHTML = ''; // On vide les 2 div
		document.getElementById(div2).innerHTML = document.getElementById(div).innerHTML;
		document.getElementById(div3).innerHTML = '';
		document.getElementById(div).innerHTML = '';
		
	}
	
	document.getElementById(div2).style.display='block';
	document.getElementById(div).style.display='block';
}

function AfficheDivLiv(valeur){
	if(valeur == true){
		jQuery('#AffLivraison').show();
	}
	else{
		jQuery('#AffLivraison').hide();
	}
}

function AfficheDivPtLiv(valeur){
	var etat_box1 = document.getElementById('form_addobject').elements['obj_typeechange'][1].checked;
	var etat_box2 = document.getElementById('form_addobject').elements['obj_typeechange'][2].checked;
	var etat_box3 = document.getElementById('form_addobject').elements['obj_typeechange'][3].checked;
	if( (valeur == true) && ( (etat_box1 == true) || (etat_box2 == true) || (etat_box3 == true) ) ){
		jQuery('#AffPointsLivraison').show();
	}
	else{
		jQuery('#AffPointsLivraison').hide();
	}
}


function RempliCoord(){
		jQuery.post("ajax/MaJCoord.php", function(data){
			if(data.length >0) {
				var reg=new RegExp("@@@","g");
				var tab= data.split(reg);
				jQuery('#obj_adresse').val(tab[0]);
				jQuery('#obj_cp').val(tab[1]);
				jQuery('#obj_ville').val(tab[2]);
				jQuery('#region').val(tab[3]);
				jQuery('#dpt').val(tab[4]);
				jQuery('#obj_tel').val(tab[5]);
			}
			
		});
}

function MaJCout(){
	cout = 2;
	if(document.getElementById('obj_teteliste').checked == true){
		cout += 2;
	}
	if(document.getElementById('obj_news').checked == true){
		cout += 2;
	}
	if(document.getElementById('code_avt').value == 1){
		cout -= 2;
	}
	if(cout == '')
		cout = '0';
	jQuery('#AffCout').html(cout);
}

function Retourne_search(f) {
  var lemot = f.value
  var exp=new RegExp("images/(.*).png");
  var occurence = exp.exec(f);
  return occurence[1];
}

function CheckCodeAvt(valeur){
	if( valeur.length < 4 ) {
		// Hide the suggestion box.
		jQuery('#AffAvantage').hide();
	} else {
		jQuery.post("ajax/MaJAvantage.php", {val: ""+valeur+""}, function(data){
			if(data.length > 0) {
				var res = Retourne_search(data);
				if(res == 'valide'){
					jQuery('#code_avt').val(1);
				}
				else{
					jQuery('#code_avt').val(0);
				}
				jQuery('#AffAvantage').show();
				jQuery('#AffAvantage').html(data);
				MaJCout();
			}			
		});
	}
}

function verif_champVide(valeur,div){
	if( valeur.length == 0 ) {
		
	}
}
function MajRecapTrocImmediat(livraison,idprod){

		jQuery.post("ajax/MaJTrocImmediat.php", {livraison: ""+livraison+"",idprod: ""+idprod+""}, function(data){
			if(data.length >0) {
				jQuery('#encart_recap_points').show();
				jQuery('#encart_recap_points').html(data);
			}
			
		});
	
}


// POUR LE MOTEUR DE RECHERCHE

function MaJSsCatRech(cat) {
	
	if(cat.length == 0) {
		// Hide the suggestion box.
		jQuery('#AffSsCat').hide();
	} else {
		jQuery.post("ajax/MaJSsCatRech.php", {cat: ""+cat+""}, function(data){
			if(data.length >0) {
				jQuery('#AffSsCat').show();
				jQuery('#AffSsCat').html(data);
			}
			
		});
	}
} // lookup

function MaJTypeRech(cat) {
	
	if(cat.length == 0) {
		// Hide the suggestion box.
		jQuery('#AffType').hide();
	} else {
		jQuery.post("ajax/MaJTypeRech.php", {cat: ""+cat+""}, function(data){
			if(data.length >0) {
				jQuery('#AffType').show();
				jQuery('#AffType').html(data);
			}
			
		});
	}
} // lookup

function MaJSsTypeRech(sscat) {
	
	if(sscat.length == 0) {
		// Hide the suggestion box.
		jQuery('#AffType').hide();
	} else {
		jQuery.post("ajax/MaJTypeRech.php", {sscat: ""+sscat+""}, function(data){
			if(data.length >0) {
				jQuery('#AffType').show();
				jQuery('#AffType').html(data);
			}
			
		});
	}
} // lookup

function MaJDptRech(region) {
	
	jQuery.post("ajax/_maj_dpt_rech.php", {region: ""+region+""}, function(data){
			if(data.length >0) {
				
				jQuery('#AffDpt').show();
				jQuery('#AffDpt').html(data);
			}
			
		});
	
} // lookup


function navig_recherche(cat,sscat,type,region,dpt,mode,page,tri,direction,nbrresultparpage){
	$('load').show();
	$('tab_recherche_ajax').style.display='none';
	new Ajax.Updater({ success: 'tab_recherche_ajax'},'ajax/_maj_recherche.php?cat='+escape(cat)+'&sscat='+escape(sscat)+'&type='+escape(type)+'&region='+escape(region)+'&dpt='+escape(dpt)+'&mode='+escape(mode)+'&page='+escape(page)+'&tri='+escape(tri)+'&direction='+escape(direction)+'&nbrresultparpage='+escape(nbrresultparpage),
	{
		method: 'get',
		onComplete: function(){
			$('load').hide();
			$('tab_recherche_ajax').style.display='block';

		}
	});
}


function navig_introkable(cat,sscat,type,region,dpt,mode,page,tri,direction,nbrresultparpage){
	$('load').show();
	$('tab_recherche_ajax').style.display='none';
	new Ajax.Updater({ success: 'tab_recherche_ajax'},'ajax/_maj_introkable.php?cat='+escape(cat)+'&sscat='+escape(sscat)+'&type='+escape(type)+'&region='+escape(region)+'&dpt='+escape(dpt)+'&mode='+escape(mode)+'&page='+escape(page)+'&tri='+escape(tri)+'&direction='+escape(direction)+'&nbrresultparpage='+escape(nbrresultparpage),
	{
		method: 'get',
		onComplete: function(){
			$('load').hide();
			$('tab_recherche_ajax').style.display='block';

		}
	});
}

function navig_evenement(cat,sscat,type,region,dpt,mode,page,tri,direction,nbrresultparpage){
	$('load').show();
	$('tab_recherche_ajax').style.display='none';
	new Ajax.Updater({ success: 'tab_recherche_ajax'},'ajax/_maj_evenement.php?cat='+escape(cat)+'&sscat='+escape(sscat)+'&type='+escape(type)+'&region='+escape(region)+'&dpt='+escape(dpt)+'&mode='+escape(mode)+'&page='+escape(page)+'&tri='+escape(tri)+'&direction='+escape(direction)+'&nbrresultparpage='+escape(nbrresultparpage),
	{
		method: 'get',
		onComplete: function(){
			$('load').hide();
			$('tab_recherche_ajax').style.display='block';

		}
	});
}

function navig_selection(cat,sscat,type,region,dpt,mode,page,tri,direction,nbrresultparpage){
	$('load').show();
	$('tab_recherche_ajax').style.display='none';
	new Ajax.Updater({ success: 'tab_recherche_ajax'},'ajax/_maj_selection.php?cat='+escape(cat)+'&sscat='+escape(sscat)+'&type='+escape(type)+'&region='+escape(region)+'&dpt='+escape(dpt)+'&mode='+escape(mode)+'&page='+escape(page)+'&tri='+escape(tri)+'&direction='+escape(direction)+'&nbrresultparpage='+escape(nbrresultparpage),
	{
		method: 'get',
		onComplete: function(){
			$('load').hide();
			$('tab_recherche_ajax').style.display='block';

		}
	});
}


function MaJTroc(troqueur) {
	
	jQuery.post("ajax/_maj_troc.php",{troqueur: ""+troqueur+""}, function(data){
			if(data.length >0) {
				
				jQuery('#AffTroc').show();
				jQuery('#AffTroc').html(data);
			}
			
		});
	
} // lookup


function MaJMemoRib(valeur) {
	
	jQuery.post("ajax/_maj_memorib.php", {valeur: ""+valeur+""}, function(data){
			if(data.length >0) {
				
				jQuery('#Affmemo').show();
				jQuery('#Affmemo').html(data);
			}
			
		});
} // lookup
