function ajoutAlerteDocument(){
	var id_membre = $('id_membre_alerte_doc').value;
	var email = $('email_alerte_doc').value.toLowerCase();
	var frequence = $('frequence_alerte_doc').value;
	var id_categorie_alerte_document = $('id_categorie_alerte_doc').value;
	
	if ((email=='') || (email.search(/^[\w\-]+(\.[\w\-]+)*@[\w\-]+(\.[\w\-]+)*\.[\w\-]{2,4}$/) == -1)){
		alert('Email absent ou non valide.');
	}else{
		var url = '/ajax/ajoutAlerteDocument.php';
		var myAjax = new Ajax.Request(
	      url,
	      {
	        method: 'post',
	        postBody: 'id_membre=' + id_membre + '&id_categorie=' + id_categorie_alerte_document + '&frequence=' + frequence + '&email=' + email,
	        onComplete: function (xhr){
			        		if (xhr.status == 200)
						    {
						    	// type de retour
						    	// ERREUR
						    	// INFO : maj alerte doc non membre
						    	// ERREUR : deja inscrit non membre
						    	// INFO : maj alerte doc membre
						    	// ERREUR : deja inscrit membre
						    	// INFO : insertion alerte non membre
						    	// ERREUR : modification compte membre
						    	// INFO : insertion alerte membre
						    
						        //$('question'+id_question).innerHTML = xhr.responseText;
						        // ERREUR
						        if (xhr.responseText=="ERREUR : deja inscrit non membre"){
						        	alert("Vous êtes déja inscrit.");
						        }
						        if (xhr.responseText=="ERREUR : deja inscrit membre"){
						        	alert("Vous êtes déja inscrit.");
						        }
						        if (xhr.responseText=="ERREUR : modification compte membre"){
						        	alert("Veuillez vous connecter pour modifier cette alerte.");
						        }
						        
						        // INFO non membre
						        if (xhr.responseText=="INFO : maj alerte doc non membre" || 
						        	xhr.responseText=="INFO : insertion alerte non membre"){
						        	//confirm("Maj non membre terminé");
						        	// redirection vers une page
						        	document.location.href="/confirmation-alerte.php";
						        }
						        
						        // INFO membre
						        if (xhr.responseText=="INFO : maj alerte doc membre" || 
						        	xhr.responseText=="INFO : insertion alerte membre"){
						        	//confirm("Maj membre terminé");
						        	//$('zone_alerte_doc').innerHTML = "Inscription terminé";
								confirm("Inscription terminé");
						        }
						    }
			        	}
	      });
	    
	}	
}


