
//version latitude 1.0
//permet de savoir si on raffraichi la page sans nouvelle identification
var justReload = false;

var MooEasyRollover = new Class({
	
	Implements: Options,
	
	options: {
		MooEasyRolloverClass: '',
		fullPath: '',
		prefix: ''
	},
	
	initialize: function(options){
	
					//////console.log("canvas1");	
					//	 	initCanvas();
		this.setOptions(options);
		this.main();
			err = false;
		//	selected_id=null;
	},
	
	
	main: function () {
		
				
		
		//vérification des formulaires
		
		
		
		
//ajoute une fonction à tous les objets possédant la classe rollover
		$$('.' + this.options.MooEasyRolloverClass).each(function (el) {
			
			var offSrc = el.getAttribute('src');
			var onSrc =  el.getAttribute('data-srcover');
var infobulle =  el.getAttribute('data-infobulle');
var overType = el.getAttribute('data-overType');
var overColor = "#"+el.getAttribute('data-overColor');
var overCible = el.getAttribute('data-overCible');
var eleIndex = el.getAttribute('data-index');
var Color = "#"+el.getAttribute('data-color');
var mode = el.getAttribute('data-alpha');
var localDroits = el.getAttribute('data-droits');

	var n=true;	

		
	if(overType == "data-img"){
		
		var tst = el.getAttribute('data-src');
		var rep= tst.indexOf('[');
		if(tst =="" || rep>=0){
			el.setStyle("visibility","hidden");
		};
	};
	
	
	
	if(overType == "img"){

	//précharge les images
			new Asset.image(onSrc);
			new Asset.image(offSrc);
			el.setStyle("cursor","pointer");
};

if(overType == "fondOver"){
		//////console.log("OverType::"+overType);
							el.setStyle("cursor","pointer");
										if(mode != null){
							el.setStyle("opacity","0.5");	
										};
			};


			el.addEvent('mouseenter', function(e) {
				e.stop();
				//	testo(e);
	
	
		
				
				
					this.setStyle("cursor","pointer");
					var cible =overCible+"-"+eleIndex;
							if(mode != null){
								el.setStyle("opacity","1");	
							};

					
					
					
				$("tooltip").setStyle("opacity","0");		
			
		
			if(this.getAttribute('data-infobulle') != null){
				if(this.getAttribute('data-infobulle') != "" ){
				infobulle = this.getAttribute('data-infobulle') ;
				sw = showTip.delay(500);	
				};
				};

		
//si overCible, le controle diffuse son message d'infobulle
	if(overCible != null){
	if(overCible != "" ){
		//	//console.log(cible+"::"+"#"+$(cible).getAttribute("data-overColor"));
	//$(e.target).setStyle("cursor","pointer");
	$(cible).setStyle('backgroundColor', "#"+$(cible).getAttribute("data-overColor"));
	if($(cible).getAttribute("data-infobulle") != null){
				if($(cible).getAttribute("data-infobulle") != "" ){
				infobulle = $(cible).getAttribute("data-infobulle") ;
				sw = showTip.delay(500);	
				};
				};
			}}
			
			
			
									$("infobulleTexte").set("text",infobulle);
						th=e.page.y-(parseInt($("tooltip").getStyle("height")));
					//	////console.log(th);
									$("tooltip").setStyle("top",th);
							$("tooltip").setStyle("left",e.page.x );
							if(overType == "img"){
					el.setAttribute('src', onSrc);
							};
						
											
							
							
				});

		////console.log(overCible);
											if(overCible != null){
if(overCible != "" ){
	
	
	var cible =overCible+"-"+eleIndex;

	
	if($(cible).getAttribute("data-type") != null  &&  $(cible).getAttribute("data-type") != ""){
		if($(cible).getAttribute("data-type") != "Zoom" &&   $(cible).getAttribute("data-type") != "youTube"){
	//el.setAttribute('href', $(cible).getAttribute("data-link"));
//	el.setAttribute('target', '_blank');
		//	//console.log("aaa");
			
			
			
/*	if(el.getAttribute("data-fcmsComposant")  != "rect"){
	var a = new Element('a',{href: $(cible).getAttribute("data-link"),target:"_self",style:"text-decoration:none"});
a.wraps(el);
			};*/
			
			/*if(el.getAttribute("data-target")  == "_blank"){
				var a = new Element('a',{href: $(cible).getAttribute("data-link"),target:"_blank",style:"text-decoration:none"});
			a.wraps(el);
						};*/
	
	
		};
	};
	
	
				el.addEvent('mousedown', function(e) {

				e.stop();	
				var cible =overCible+"-"+eleIndex;
				paramV ="";
			

				

				
	//	////console.log(cible+"::"+""+$(cible).getAttribute("data-link"));
if($(cible).getAttribute("data-memVar") != null){
			if($(cible).getAttribute("data-memVar") != "" ){
		memvar = $(cible).getAttribute("data-memVar") ;
		memchamp = $(cible).getAttribute("data-memchamp") ;
		paramV = "&memVar="+memvar+"&memChamp="+memchamp;
			};
			};
		//	//console.log("'"+$(cible).getAttribute("data-typeLien")+"'")
if($(cible).getAttribute("data-type") != null  &&  $(cible).getAttribute("data-type") != ""){
						if($(cible).getAttribute("data-type") == "Zoom"){
							
						/*var L = $(cible).getAttribute("data-link");		
L = L.replace("deploy.","deploy");
L = L.replace("_i","_z");
//////console.log("mmmmm");
Mediabox.open(L, $(cible).getAttribute("data-titre"));
//window.location.href = $(cible).getAttribute("data-link")+paramV;*/
							//index data de l'enregistrement
				
							simpleDiaporamaInstance.showZ($(cible).getAttribute("data-recId"),"image",$(cible).getAttribute("data-src"));

						}else if ($(cible).getAttribute("data-type") == "Youtube"){
							////console.log($(cible).getAttribute("data-link"));
//var idYT ="http://www.youtube.com/embed/"+ $(cible).getAttribute("data-link");
//////console.log(idYT);
//Mediabox.open(idYT, $(cible).getAttribute("data-titre"));
							simpleDiaporamaInstance.showZ($(cible).getAttribute("data-src"),"youTube",$(cible).getAttribute("data-src"));
}	else{
	//window.location.target="_new";
	//simpleDiaporamaInstance.showZ($(cible).getAttribute("data-src"),"youTube");
	//window.open($(cible).getAttribute("data-link"));
//	window.location.href = $(cible).getAttribute("data-link");
	
	if($(cible).getAttribute("data-target") == "_blank"){

		window.open($(cible).getAttribute("data-link"), '_new');
	}else{
		window.location.href = $(cible).getAttribute("data-link");
	}
	
	
	/*var a = new Element('a',{
		  href: $(cible).getAttribute("data-link"),
		  target:"_blank"
		});	
	//console.log("--"+a);
		a.inject(el);*/
};

}else{
	window.location.href = $(cible).getAttribute("data-link")+paramV;

//
};


	
		
			});
			}
};
			
			if(el.getAttribute("data-type") == "Zoom"){
				el.addEvent('mousedown', function(e) {

					e.stop();	

				simpleDiaporamaInstance.showZ(el.getAttribute("data-recId"),"image",el.getAttribute("data-src"));
				});
			};
			

			
			
			
			
			el.addEvent('mousemove', function(e) {
				e.stop();
				if(this.getAttribute('data-infobulle') == null){
					$("tooltip").setStyle("opacity","0");
				};
				if(this.getAttribute('data-infobulle') == ""){
					$("tooltip").setStyle("opacity","0");
				};
		th=e.page.y-(parseInt($("tooltip").getStyle("height")));
			////////console.log(th);
		
								$("tooltip").setStyle("top",th-10);
						$("tooltip").setStyle("left",e.page.x-40);
			
			});
			
			if( overType == "textarea" && el.getAttribute('data-record')=="Oui"){
				
				//enregistre en temps réel les changements de valeur dans le champ
				el.addEvent('keyup', function(e) {
					
					rec_one(el.getAttribute('data-table'),el.getAttribute('data-champ'),el.getAttribute('data-id'),el.value)
				});
				
				
			}	;
			
			
			
if(overType == "textinput" || overType == "textarea"|| overType == "select" || overType ==  "adresseMail"){
			el.addEvent('focus', function(e) {
			//////console.log("erreur"+err);
					if(err){
					
						this.setAttribute('text',"");
						effaceErreur(this);
					};
							el.setStyle('color', '#000000');
						el.setStyle('backgroundColor', '#eeeeee');
		
			});
			};
						if(overType == "textinput" || overType == "textarea"|| overType == "select" || overType ==  "adresseMail"){		
				el.addEvent('blur', function(e) {

						el.setStyle('backgroundColor', '#FFFFFF');
	
			});
	};
			
			el.addEvent('mouseleave', function(e) {
				e.stop();
					//	////console.log("leave");		
	
				if(this.getAttribute('data-infobulle') != null && this.getAttribute('data-infobulle') != "" ){
					if(sw != undefined){
						clearTimeout(sw);
					};
				
									$("tooltip").setStyle("opacity","0");
						};
						//////console.log(
						if(mode != null  && this.getAttribute('data-selected')!='true'){
							el.setStyle("opacity","0.5");	
						}
						$("tooltip").setStyle("opacity","0");
		if(overType == "img"){
						el.setAttribute('src', offSrc);
		};
		
//changement couleur fondOver		
var cible =overCible+"-"+eleIndex;
if(overCible != null){
if(overCible != "" ){
$(cible).setStyle('backgroundColor', "#"+$(cible).getAttribute("data-Color"));
		}
		}
//-fin changement de couleur		
			});		
			
		//	if(overCible != null){
		//	if(overCible != "" ){


			if(overType == "img"){
				el.setStyle("cursor","pointer");
			el.addEvent('mousedown', function(e) {
				e.stop();

				//si les droits actuels de l'utilisateur ( enregistrés dans un cookie) , sont inférieurs aux droits requis pour suivre le lien
				//Il serait bien de=: action-type à ajouter: "Lien conditionnel"
			//	//console.log(parseInt(localDroits));
		//		//console.log(Cookie.read('droits'));
				if(Cookie.read('droit') == null) {
					Cookie.write('droit', "0", {duration: 365});
				}else{
					if(Cookie.read('droit').length == 0){
						Cookie.write('droit', "0", {duration: 365});
					};
					
				};
			//	console.log(Cookie.read('droit'));
				if(parseInt(Cookie.read('droit')) <  1 &&  parseInt(localDroits)==1 ) 	{
					
					
									if (confirm("Vous devez vous inscrire pour pouvoir b\351n\351ficier de cette fonctionnalit\351, souhaitez-vous continuer?")) { 
										//le système a détecter que la personne n'est pas identifiée
										//redirection vers la page d'inscription
										//écrit dans un cookie le nom de la page à atteindre à l'issue de l'inscription
									Cookie.write('linkIfOk', (this.getAttribute("data-link")));
									window.location = "../php/readPageId.php?id=133";
									};
					

				}else if(parseInt(Cookie.read('droit')) <  parseInt(localDroits) ){
					
					
					
					
				}else{
		//			//console.log(this.getAttribute('data-actionType'));
					//va directement à la page voulue
					if(this.getAttribute('data-actionType')=="RecupMDP"){
						recupMdp();
				}else if(this.getAttribute('data-actionType')=="Deconnecter"){
					destroyLogin();
		 				Cookie.dispose('login');
					  	Cookie.dispose('pass');
					  	Cookie.write('droit',0);
					  						  	Cookie.dispose('nom');
					  						  						  	Cookie.dispose('prenom');
					  						  						  						  	Cookie.dispose('idUser');
					  						  						  	
						$('login').set("value","");
						$('pass').set("value","");
					var 	inner = '<p style="margin:0;text-align:left;"><span style="font-family:Arial; font-size:12px; color:#D1D672;">D\351connect\351</span></p>';
					$('enLigne').set("html",inner);
					//Cookie.write('justReload','true');
			//		window.location.href = this.getAttribute("data-link");
					window.location.reload();
				}else if(this.getAttribute('data-actiontype')=="Login"){	
					
				//	console.log(Cookie.read('logdroit'))
	connectLogin();
					
				}else{
			
					window.location.href = this.getAttribute("data-link");
				};
				};
			});		
			};
			
			
		
			
			
			
			
			
		}, this);				
		
		
			
		
	}



});


function showTip () {
	$("tooltip").setStyle("opacity","1");
	/*var myEffect = new Fx.Morph("tooltip", {
    duration:250,
    transition: Fx.Transitions.Sine.easeOut
});
 
myEffect.start({
    'opacity': [0, 1]
});

	
	*/
	
				//	$("tooltip").setStyle("opacity","1");
		};

function validation(test,_idRec,_pageCible){
err = false;
	var m1 = "";
	var   m2= "";
	var ele1;
	var ele2;
	var champs = new Array();
	var donnees = new Array();
	var mailOK = false;
	var idRec=_idRec;
	var mail="";
	var pageCible= _pageCible;
	var idForm = $(test).getAttribute('data-formname');
	var actionType = $(test).getAttribute('data-actionType');
	var table = $(test).getAttribute('data-table');
	//////console.log("pp"+actionType);
	var sessNom="";
	var sessPrenom ="";
	
		switch (actionType) {
 case "Annuler":
 		window.location.href = "../php/readPageId.php?id=128";
	//parent.window.location.reload();
	
 break;
 case "HistoryBack":
	 window.history.back();
	 break;
 

 case "Valider":
case "Inscription":
case "InscriptionSeule":	
	$('form'+idForm).getElements("textarea,input,select,checkbox,radio,div").each(

		function(el){
			var verif = el.getAttribute('data-verif');
			var typo = el.getAttribute('data-overType');

		
			if(el.getAttribute('data-champ') != null){
				console.log("---"+typo);
				
				switch(typo){
				case "adresseMail":
								if(typo == "adresseMail" && mailOK==false){
					mailOK = true;
						champs.push(el.getAttribute('data-champ'));
							donnees.push(el.value);
							
							
				}else if(typo != "adresseMail" && typo!="checkbox"){
			champs.push(escape(el.getAttribute('data-champ')));
			donnees.push(el.value);
				}
								break;
				case "checkbox"	:			

				champs.push(el.getAttribute('data-champ'));
				donnees.push(el.checked);
	
								break;
				case "radio"	:			
if(el.checked == true){
					champs.push(el.getAttribute('data-champ'));
					donnees.push(el.value);
					//donnees.push(el.checked);
};
									break;
				case "select"	:			

					champs.push(el.getAttribute('data-champ'));
					donnees.push(el.value);
		
									break;

				case "textarea"	:			

				champs.push(el.getAttribute('data-champ'));
				donnees.push(el.value);
				if(el.getAttribute('data-champ') == "nom"){
					sessNom = el.value;
				};
				if(el.getAttribute('data-champ') == "prenom"){
					sessPrenom = el.value;
				};
								break;
				case "dateur":			
	
				champs.push(el.getAttribute('data-champ'));
				donnees.push(el.value);
	
								break;
				case "inputImage"	:			
			

		var nImage = "imgToUpload-"+el.getAttribute('data-index');

				champs.push(el.getAttribute('data-champ'));
				donnees.push($(nImage).get("text"));
			
								break;
			}; //fin switch
			};
			if(verif == "Obligatoire"){
if(typo == "inputImage"){

	var nImage1 = "imgToUpload-"+el.getAttribute('data-index');
	if($(nImage1).get("text") ==""){
		err = true;
		entoureErreur(el, "Champ obligatoire");
	}
	
}
		if(typo == "adresseMail"){
			
	
			
							if(el.getAttribute('id') == ("adresseMail1"+idForm)){
							m1=  $(el).value;
							ele1 = el;
								//	////console.log("uu"+m1);
																}else if(el.getAttribute('id') == ("adresseMail2"+idForm)){
							m2 = $(el).value;
							ele2 = el;
							mail = $(el).value;
								//	////console.log("k"+m2);
							};
										//	////console.log("formulaire"+el.getAttribute('id')+"::"+verif+el.get('type'));
						//	////console.log(checkEmail(el.getAttribute('value')));
					}else{
		//////console.log(estVide($(el).value));
											
					};//if typo
					if(estVide($(el).value) && typo != "inputImage"){
						err = true;
							entoureErreur(el, "Champ obligatoire");
					};

					
			}
					}  						 //el
		);//fin each
		
		if(m1 != m2){
				err = true;
			//alert ("Erreur de saisie");
			entoureErreur(ele1, "Erreur de saisie");
		entoureErreur(ele2 , "Erreur de saisie");
		
		};
		
		if(err == false){
		//	////console.log(champs);
			//////console.log(donnees);
			if(actionType != "Valider"){
			champs.push("droit");
			donnees.push("1");
			champs.push("pass");
			donnees.push("password");
			};
			
envoiFormulaire(actionType,table,champs,donnees,mail,idRec,pageCible,sessNom,sessPrenom);
		}else{
alert("Le formulaire comporte des erreurs ou des oublis, les champs \340 corriger sont signal\351s en gris.");		
 window.scrollTo(0,0);

		};

//	alert("ooooo"+test);
break;

///update

case "Update":
	
	$('form'+idForm).getElements("textarea,input,select,checkbox,div").each(

		function(el){
			var verif = el.getAttribute('data-verif');
			var typo = el.getAttribute('data-overType');

			
			if(el.getAttribute('data-champ') != null){
				switch(typo){
				case "adresseMail":
								if(typo == "adresseMail" && mailOK==false){
					mailOK = true;
						champs.push(el.getAttribute('data-champ'));
							donnees.push(el.value);
							
							
				}else if(typo != "adresseMail" && typo!="checkbox"){
			champs.push(escape(el.getAttribute('data-champ')));
			donnees.push(el.value);
				}
								break;
				case "checkbox"	:			

				champs.push(el.getAttribute('data-champ'));
				donnees.push(el.checked);
	
								break;
								
				case "select"	:			

					champs.push(el.getAttribute('data-champ'));
					donnees.push(el.value);
		
									break;

				case "textarea"	:			

				champs.push(el.getAttribute('data-champ'));
				donnees.push(el.value);
				if(el.getAttribute('data-champ') == "nom"){
					sessNom = el.value;
				};
				if(el.getAttribute('data-champ') == "prenom"){
					sessPrenom = el.value;
				};

	
								break;
				case "dateur":			
	
				champs.push(el.getAttribute('data-champ'));
				donnees.push(el.value);
	
								break;
				case "inputImage"	:			
			

		var nImage = "imgToUpload-"+el.getAttribute('data-index');

				champs.push(el.getAttribute('data-champ'));
				donnees.push($(nImage).get("text"));
			
								break;
			}; //fin switch
			};
			
			
			if(verif == "Obligatoire"){

		if(typo == "adresseMail"){
			
	
			
							if(el.getAttribute('id') == ("adresseMail1"+idForm)){
							m1=  $(el).value;
							ele1 = el;
								//	////console.log("uu"+m1);
																}else if(el.getAttribute('id') == ("adresseMail2"+idForm)){
							m2 = $(el).value;
							ele2 = el;
							mail = $(el).value;
								//	////console.log("k"+m2);
							};
										//	////console.log("formulaire"+el.getAttribute('id')+"::"+verif+el.get('type'));
						//	////console.log(checkEmail(el.getAttribute('value')));
					}else{
		//////console.log(estVide($(el).value));
											
					};//if typo
					if(estVide($(el).value) && typo != "inputImage"){
						err = true;
							entoureErreur(el, "Champ obligatoire");
					};

					
			}
					}  						 //el
		);//fin each
		
		if(m1 != m2){
				err = true;
			//alert ("Erreur de saisie");
			entoureErreur(ele1, "Erreur de saisie");
		entoureErreur(ele2 , "Erreur de saisie");
		
		};
		
		if(err == false){
		
//envoiFormulaire(actionType,table,champs,donnees,mail,idRec,pageCible);
envoiFormulaire(actionType,table,champs,donnees,mail,idRec,pageCible,sessNom,sessPrenom);
		}else{
alert("Le formulaire comporte des erreurs ou des oublis, les champs \340 corriger sont signal\351s en gris.");		
 window.scrollTo(0,0);

		};

//	alert("ooooo"+test);
break;
///fin update
 };//fin switch actionType

};//fin validation


function envoiFormulaire(_typ,_table,_champs,_donnees,_mail,_idRec,_pageCible,_nom,_prenom){
	////console.log(_typ);
	switch (_typ) {
	
	 case "Valider":
		 scriptPhp = "ajouteRecAjax.php";
		  break;
 case "Inscription":
scriptPhp = "inscriptionAjax.php";
 break;
 case "InscriptionSeule":
	 scriptPhp = "inscriptionAjaxSeule.php";
	  break;
 case "Update":
	 scriptPhp = "updateAjax.php";
	  break;
 }
	
	
	var ch="";
for (i=0;i<_champs.length;i++){
	if(i<(_champs.length-1)){
	ch+=_champs[i]+"#";
	}else{
		ch+=_champs[i];
	}
};

var d="";
for (i=0;i<_donnees.length;i++){
	if(i<(_donnees.length-1)){
	d+=_donnees[i]+"#";
	}else{
		d+=_donnees[i];
	}
};
d =  Remplace(d,"'","&apos;");
 var jsonReq = new Request.JSON({
      url: '../php/'+scriptPhp,
      method: 'post',
      data: {
        typ: _typ,
       table: _table,
        champs:ch,
        donnees:d,
        id:_idRec,
        mail:_mail,
        nom:_nom,
        prenom:_prenom
      },  
      
      
      
      
		onSuccess: function(rep){
			// Hide loading and show success for 3 seconds.

			 
			 			if(rep.reponse=="Erreur"){
			 				
			alert("Erreur de saisie, recommencez");
						}else if(rep.reponse == "okUpdate"){
							if(_pageCible){
							///	window.location.href = "../php/readPageId.php?id="+_pageCible;
								 window.history.back();
							}else{
								alert("Enregistrement valid\351")
								
							}
							
							
						}else if(rep.reponse == "exist"){
				
							alert("Vous \352tes d\351ja inscrit !");
							
						}else if(rep.reponse == "InscriptionSeule"){
							
							if(_pageCible){
							window.location.href = "../php/readPageId.php?id="+_pageCible;
						
								}else{
									alert("Enregistrement valid\351")
									
								}
							
						}else{
							if(_pageCible){
								window.location.href = "../php/readPageId.php?id="+_pageCible;
							
									}else{		
			
							//encodage octal des messages javascript pour les caractères spéciaux.
			alert("Votre inscription est r\351ussie, vous allez bient\364t re\347evoir un mail de confirmation avec vos identifiants, mais vous pouvez d\350s maintenant  d\351couvrir notre site...bonne visite!");
									};
			if(rep.login){
			Cookie.write('login', rep.login);
			Cookie.write('pass', rep.pass);
			};
			
			if(Cookie.read('linkIfOk')){
	window.location.href = Cookie.read('linkIfOk');
			Cookie.dispose('linkIfOk');
			}else{
		//	window.location.href = "../php/readPageId.php?id=128";
			};

			};
			
			
			
		}
		/*,
		onFailure: function(){
			// Hide loading and show fail for 3 seconds.
			showHide( 'fail' );
		}*/
	});
	
		jsonReq.send();
	
	
	
	
	
	
	
	
}//fin envoi formulaire








function entoureErreur(elem, msg){
	
	//$(elem).setStyle("border","solid");
	//$(elem).setStyle("borderWidth","1");
	$(elem).setStyle("backgroundColor","#70706F");
	$(elem).setStyle("color","#FFFFFF");
//	$(elem).value = msg;
	$(elem).setAttribute('data-infobulle',msg);
};

function effaceErreur(elem){
	
//$(elem).setStyle("backgroundColor","#70706F");
	$(elem).setStyle("color","#000000");
		$(elem).setStyle("borderWidth","0");
		$(elem).value = "";
		$(elem).setAttribute('data-infobulle',"");
		
		};




/*function checkEmail(adr1) {		adresse1 = adr1;		var errMsg;		if(adresse1 && !estVide(adresse1)) {			if(adresse1.length > 100)				errMsg = msg["toolong"];			else {				var atom = "[!#-'*+\\-\\/-9=?A-Z^-~]+";				var regex_adresse =					new RegExp("^"+atom+"(\\."+atom+")*@"+atom+"(\\."+atom+")*\\.[a-zA-Z]{2,4}$");				if(adresse1.search(regex_adresse) != 0){					errMsg = msg["invalid"];				}			}		}		else {			errMsg = msg["mailrequired"];		}		if(errMsg){			erreurs.push(errMsg);		return errMsg;		}	}function confirmeEmail(adresse2) {		if(adresse2) {			if(adresse1 && (adresse2 != adresse1))				erreurs.push(msg["different"]);		}		else if(champsObligatoires["email2"]){			erreurs.push(msg["confirm"]);		}	}*/
	
	/*
	 * Fonction vérifiant qu'un champ est rempli.
	 * On vérifie que la valeur n'est ni vide ni constituée uniquement d'espaces.
	 */
		function rec_one(_table,_champ,_id,_val){
			var jsonReq2 = new Request.JSON({
			      url: '../php/rec_one_value_ajax.php',
			      method: 'post',
			      data: {
			       table: _table,
			        champ:_champ,
			        valeur:_val,
			        id:_id
			      },  
			      
			      
			      
			      
					onSuccess: function(rep){

						 			if(rep.reponse=="Erreur"){
						 				
						alert("Erreur de saisie, recommencez");
									}
						
					}
				
				});
				
					jsonReq2.send();
				
		};

		function Remplace(expr,a,b) {
		      var i=0
		      while (i!=-1) {
		         i=expr.indexOf(a,i);
		         if (i>=0) {
		            expr=expr.substring(0,i)+b+expr.substring(i+a.length);
		            i+=b.length;
		         }
		      }
		      return expr
		   }; 
	function estVide(valeur) {
		return !valeur || (valeur.search(/^\s+$/) == 0);
// On vérifie que la valeur n'est ni vide ni constituée d'un seul caractère répété.
//		return (!valeur || (valeur.search(/^[\n\r]*(.)\1*[\n\r]*$/) >= 0));
	}

	function white_space(v)
	{
	     return v.replace(/^\s*|\s*$/g,'');
	}
