function AjaxUpdate(artid,type,value){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			//document.myForm.time.value = ajaxRequest.responseText;
		}
	}
	var artid = artid;
	var type = type;
	var value=value ;
	var queryString = "?artid=" + artid + "&type=" + type +"&value="+ value;
	//alert(queryString) ;
	ajaxRequest.open("GET", "ajax/updatearticle.php" + queryString, true);
	ajaxRequest.send(null); 
}

function fill_combo(data, page, method, elem)
{
    if(window.ActiveXObject)
    {
        //Internet Explorer
        var FerTedObjc = new ActiveXObject("Microsoft.XMLHTTP") ;
    }//fin if
    else
    {
        //Mozilla
        var FerTedObjc = new XMLHttpRequest();
    }//fin else
    
    //définition de l'endroit d'affichage:
    var content = document.getElementById(elem);
    
    //si on envoie par la méthode GET:
    if(method == "GET")
    {
        if(data == 'null')
        {
            //Ouverture du fichier sélectionné:
            FerTedObjc.open("GET", page);
        }//fin if
        else
        {
            //Ouverture du fichier en methode GET
            FerTedObjc.open("GET", page+"?"+data);
        }//fin else
    }//fin if
    else if(method == "POST")
    {
        //Ouverture du fichier en methode POST
        FerTedObjc.open("POST", page);
    }//fin elseif
    FerTedObjc.onreadystatechange = function()
    {
		//tant que la réponse n'est pas arrivé afficher l'image d'attente
		if (FerTedObjc.readyState < 4){
			
			content.innerHTML = '<img src="test.gif">';
		}
		else {
		//sinon retourner la réponse	
		content.innerHTML = FerTedObjc.responseText;
		
		}
    }    
    if(method == "GET")
    {
        FerTedObjc.send(null);
    }//fin if
    else if(method == "POST")
    {
        FerTedObjc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        FerTedObjc.send(data);
		
    }//fin elseif
}//fin fonction iLanceLoZaFair
function display_city(zip){
}

function cat_update(id) {
	new Ajax.Request('ajax/cat_update.php?cat_id='+id+'&val='+ document.getElementById('pos_'+id).value ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;

				
  },
  onFailure: function(){ alert('Something went wrong...') }
});	
}
function encart_postion(id){
	new Ajax.Request('ajax/cat_update.php?encart_id='+id+'&val='+ document.getElementById('pos_'+id).value ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;

				
},
onFailure: function(){ alert('Something went wrong...') }
});		
}

function encart_visible(id){
	
	var val = document.getElementById('vis_'+id).checked ;
	switch (val){
	case true :
		val=1 ;
		break ;
	case false:
		val = 0 ;
		break ;
	}
	new Ajax.Request('ajax/cat_update.php?id_visible='+id+'&val='+ val ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;

				
},
onFailure: function(){ alert('Something went wrong...') }
});		
}

function admin_menu_update(type,id){
	switch(type){
	case 1 :
		var val = document.getElementById('menutype').value ;
		new Ajax.Request('ajax/cat_update.php?menu_id='+id+'&val='+ val ,
				  {
				    method:'get',
				    onSuccess: function(xhr){
					var response = xhr.responseText ;
					
					},
						onFailure: function(){ alert('Something went wrong...') }
				  	});
		break ;
	case 2:
		var val = document.getElementById('orders_'+id).value ;
		new Ajax.Request('ajax/cat_update.php?men_id='+id+'&val='+ val ,
				  {
				    method:'get',
				    onSuccess: function(xhr){
					var response = xhr.responseText ;
					//alert(response);
					
					},
						onFailure: function(){ alert('Something went wrong...') }
				  	});
		break ;
}
}
function coaching_postion(id){

	new Ajax.Request('ajax/cat_update.php?coaching_id='+id+'&val='+ document.getElementById('pos_'+id).value ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;

				
},
onFailure: function(){ alert('Something went wrong...') }
});		
}

function article_update(id,type){
	new Ajax.Request('ajax/cat_update.php?article_id='+id+'&type='+type+'&val='+ $('artpos_'+id).value ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;		
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
}
function check_equipe(id,value){
	if(value=='on'){
		val = 1 ;
	} else {
		val = 0 ;
	}
	
	new Ajax.Request('ajax/cat_update.php?societe_id='+id+'&val='+ val ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;		
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
}
function check_herbalife_id(){
	var id = $('vherbalife_id').value ;
	new Ajax.Request('ajax/inscription.php?type=1&id='+id ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				
				if(response=='existe'){
					var y=document.createElement('span');
					y.innerHTML='Veuillez r\351essayer avec un autre num\351ro, celui-ci  est utilis\351 par un autre Distributeur';
					alert(y.innerHTML);
					$('vherbalife_id').value = "";
					checkform2();
				}
				
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
}
function check_email_exist(field){
	var email = $(field).value ;
	new Ajax.Request('ajax/inscription.php?type=2&email='+email ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				
				if(response=='existe'){
					alert('cet email existe d\351j\340');
					window.location="index.php?p=error&id=12";
				}
				
				
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
}
function delete_message_mur(id){
	new Ajax.Request('ajax/prospect.php?type=7&id='+id , 
	  {
	    method:'get',
	    onSuccess: function(xhr){
		var response = xhr.responseText ;
		
},
onFailure: function(){ alert('Something went wrong...') }
});
}
function pret_facture(id){
	var value = $('facture').value ;
	new Ajax.Request('ajax/stock.php?p=6&id='+id+'&val='+value , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}
function renouveller_licence(id){

	new Ajax.Request('ajax/inscription.php?type=3&id='+id , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				var data = response.split('/') ;
				alert("Ann\351es renouvell\351e(s) :" + data[1]);
				var date_renew = data[0].split('-') ;
				date_renew1 = date_renew[2] +"-"+ date_renew[1]+"-"+date_renew[0];
				//alert(date_renew1);
				$('renewal').innerHTML = date_renew1 ;
				
				
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
	
}
function renouveller_licence_annee(id){
	new Ajax.Request('ajax/inscription.php?type=4&id='+id , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				var data = response.split('/') ;
				alert("Ann\351es renouvell\351e(s) : 1");
				var date_renew = data[0].split('-') ;
				date_renew1 = date_renew[2] +"-"+ date_renew[1]+"-"+date_renew[0];
				//alert(date_renew1);
				$('renewal').innerHTML = date_renew1 ;
				
				
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}

function reduire_licence_an(id){
	new Ajax.Request('ajax/inscription.php?type=6&id='+id , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				var data = response.split('/') ;
				//alert("Ann\351es renouvell\351e(s) : 1");
				var date_renew = data[0].split('-') ;
				date_renew1 = date_renew[2] +"-"+ date_renew[1]+"-"+date_renew[0];
				//alert(date_renew1);
				$('renewal').innerHTML = date_renew1 ;
				
				
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}

function update_facture_pret(id){
	var val = $('facture_'+id).value ;
	new Ajax.Request('ajax/stock.php?p=6&id='+id+'&val='+val , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				//alert('in');
				var response = xhr.responseText ;
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}
function coaching_visible(id,societe,type){
	val = $('vis_'+id).checked ;
	new Ajax.Request('ajax/stock.php?p=7&id='+id+'&val='+val+'&societe='+societe+'&type='+type, 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				//alert('in');
				var response = xhr.responseText ;
				//alert(response);
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
	
}
function rdv_add_test(bname){
	
	hour =$(bname).value ;
	minutes = hour.substring(3,5);
	
	switch(minutes){
	case "00":
	case "15":
	case "30":
	case "45":
		ok = true ;
		break ;
	default :
		$(bname).value ="00:00";
		alert('Les minutes seulement 00 ou 15 ou 30 ou 45') ;
		ok = false ;
		break ;
	}
	
	
}

function coaching_distri_date_update(id,societe){
	val = $('date_'+id).value ;
	hour = $('hour_'+id).value;

	minutes = hour.substring(3,5);

	switch(minutes){
	case "00":
	case "15":
	case "30":
	case "45":
		ok = true ;
		break ;
	default :
		$('hour_'+id).value ="";
		alert('Les minutes seulement 00 ou 15 ou 30 ou 45') ;
		ok = false ;
		
		break ;
	}
	
	if(hour!='00:00'){
		
		newdate = val.split('-');
		datet = newdate[2]+'-'+newdate[1]+'-'+newdate[0];
		distri = $('distri').value ;
		//alert(distri);
		
		new Ajax.Request('ajax/stock.php?p=17&id='+distri+'&bdate='+datet+'&hour='+hour, 
				  {
				    method:'get',
				    onSuccess: function(xhr){
					//alert('in');
					var response = xhr.responseText ;
					if(response=='NOK'){
						alert('Il y a deja un RDV');
						ok = false ;
						$('date_'+id).value ='00-00-0000';
						$('hour_'+id).value ='00:00';
						
						val = '00-00-0000';
						hour = '00:00' ;
						
						new Ajax.Request('ajax/stock.php?p=23&id='+id+'&val='+val+'&societe='+societe+'&hour='+hour+'&distri='+distri, 
								  {
								    method:'get',
								    onSuccess: function(xhr){
									//alert('in');
									var response = xhr.responseText ;
									//alert(response);
									
							},
							onFailure: function(){ alert('Something went wrong...') }
							});
						
						
					}	 else {
						if (ok==true)
							new Ajax.Request('ajax/stock.php?p=23&id='+id+'&val='+val+'&societe='+societe+'&hour='+hour+'&distri='+distri, 
									  {
									    method:'get',
									    onSuccess: function(xhr){
										//alert('in');
										var response = xhr.responseText ;
										//alert(response);
										
								},
								onFailure: function(){ alert('Something went wrong...') }
								});
					
					}
					
			},
			onFailure: function(){ alert('Something went wrong...') }
			});
		
		
	}
	
	
	
	
}


function coaching_date_update(id,societe){
	val = $('date_'+id).value ;
	hour = $('hour_'+id).value;
	
	minutes = hour.substring(3,5);
	//alert(minutes);
	switch(minutes){
	case "00":
	case "15":
	case "30":
	case "45":
		ok = true ;
		break ;
	default :
		$('hour_'+id).value ="";
		alert('Les minutes seulement 00 ou 15 ou 30 ou 45') ;
		ok = false ;
		
		break ;
	}
	if(hour!='00:00')
	
	newdate = val.split('-');
	datet = newdate[2]+'-'+newdate[1]+'-'+newdate[0];
	distri = $('distri').value ;
	//alert('ajax/stock.php?p=17&id='+distri+'&bdate='+datet+'&hour='+hour);
		
	new Ajax.Request('ajax/stock.php?p=17&id='+distri+'&bdate='+datet+'&hour='+hour, 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				//alert('in');
				var response = xhr.responseText ;
				if(response=='NOK'){
					alert('Il y a deja un RDV');
					ok = false ;
					$('date_'+id).value ='00-00-0000';
					$('hour_'+id).value ='00:00';
					
					val = '00-00-0000';
					hour = '00:00' ;
					
					new Ajax.Request('ajax/stock.php?p=8&id='+id+'&val='+val+'&societe='+societe+'&hour='+hour, 
							  {
							    method:'get',
							    onSuccess: function(xhr){
								//alert('in');
								var response = xhr.responseText ;
								//alert(response);
								
						},
						onFailure: function(){ alert('Something went wrong...') }
						});
					
					
				}	 else {
					if (ok==true)
						new Ajax.Request('ajax/stock.php?p=8&id='+id+'&val='+val+'&societe='+societe+'&hour='+hour, 
								  {
								    method:'get',
								    onSuccess: function(xhr){
									//alert('in');
									var response = xhr.responseText ;
									//alert(response);
									
							},
							onFailure: function(){ alert('Something went wrong...') }
							});
				
				}
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
	
	
	//alert(ok);
	
	
	
}
function member_update_orga(id){
	val=$('orga').value ;
	new Ajax.Request('ajax/stock.php?p=9&id='+id+'&val='+val , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				//alert('in');
				var response = xhr.responseText ;
				//alert(response);
				
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}
function coaching_photo_data(id){
	val=$('datephoto_'+id).value ;
	new Ajax.Request('ajax/stock.php?p=10&id='+id+'&val='+val , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				//alert('in');
				var response = xhr.responseText ;
			
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}
function coaching_question_order(id){
	val =$('orders_'+id).value ;
	new Ajax.Request('ajax/stock.php?p=11&id='+id+'&val='+val , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				//alert('in');
				var response = xhr.responseText ;
				//alert(response);
			
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}
function coaching_distri_question_order(id){
	val =$('orders_'+id).value ;
	new Ajax.Request('ajax/stock.php?p=12&id='+id+'&val='+val , 
			  {
			    method:'get',
			    onSuccess: function(xhr){
				//alert('in');
				var response = xhr.responseText ;
				//alert(response);
			
		},
		onFailure: function(){ alert('Something went wrong...') }
		});
}
function check_email_exist_profil(field,id){
	var email = $(field).value ;
	
	new Ajax.Request('ajax/inscription.php?type=5&email='+email+'&id='+id ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				
				if(response=='existe'){
					alert('cet email existe d\351j\340');
					window.location="index.php?p=error&id=12";
				}
				
				
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
}
function inscription_event(id,societe){
	val=$('partic_'+id).checked ;
	if(!societe){
		alert('inscrivez vous pour participer aux eventements!;') ;
		window.location="index.php?p=inscription";	
	}
	
	new Ajax.Request('ajax/stock.php?p=19&id='+id+'&val='+val+'&societe='+ societe ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				
				if(response=="NOK"){
					alert('Il y a deja un RDV');
					$('partic_'+id).checked=false ;
				} else {
				
					new Ajax.Request('ajax/stock.php?p=13&id='+id+'&val='+val+'&societe='+ societe ,
							  {
							    method:'get',
							    onSuccess: function(xhr){
								var response = xhr.responseText ;
								
								if(response=="NOK"){
									alert('Il y a deja un RDV');
									$('partic_'+id).checked=false ;
								}
								
								//alert(response);
							
					},
					onFailure: function(){ alert('Something went wrong...') }
					});
				
				}
				
				//alert(response);
			
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
	
	
	
	
	
}
function check_event(id){
	$('partic_'+id).checked = true ;
}
function check_dossier(id){
	new Ajax.Request('ajax/stock.php?p=15&id='+id ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				if(response==1){
					alert('Votre dossier n\'est pas vide !!!')
				} else {
					$('dossierdelid').value = id ;
					$('dossier_delete_ft').submit();
				}
				//alert(response);
			
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
}
function event_add(){
	bdate = $('dateb').value ;
	edate = $('datee').value ;
	bhour = $('hoursb').value ;
	ehour = $('hourse').value ;
	id = $('societe').value;
	
	new Ajax.Request('ajax/stock.php?p=18&id='+id+'&bdate='+bdate+'&edate='+ edate+'&hour='+bhour+'&hour2='+ehour ,
			  {
			    method:'get',
			    onSuccess: function(xhr){
				var response = xhr.responseText ;
				//alert(response);
				if(response=='NOK'){
					alert('Il y a deja un RDV');
				} else {
					$("eventfrm").submit();
				}
			
	},
	onFailure: function(){ alert('Something went wrong...') }
	});
	
}


