// JavaScript Document POUR LE DOCUMENT PRINCIPALE (BAS.PHP)



function nettoie (r)

	{
	
	r=r.replace(/^\s+|\s+$/g,""); // trim 	
	r=r.toLowerCase();
	r = r.substring(0,1).toUpperCase() +r.substring(1,r.length); //capitalize first letter

    //r = r.replace(new RegExp("\\s", 'g'),"");
    r = r.replace(new RegExp("[\n0123456789@#!$%?&<>:;.,+]", 'g'),"");
	return r;
	


	}
	 

function ilclique(id2)
	{
	FermeLesAutres();
	//alert ('dans ilclique '+document.getElementById(id2).className);

	if (!clic[id2]) 
		{
		valeur_initial[id2] =  document.getElementById(id2).value
		}
	document.getElementById(id2).style.background="#FFFF99";	
	clic [id2] = true; // pour indiquer que ce id à été cliquer
 	document.getElementById(id2).readOnly =  false;
 	document.getElementById(id2).className = "bb1";
	document.getElementById(id2).focus();
	//alert ('dans ilclique '+document.getElementById(id2).className);

	}

function RaZ_tous()
	{
	for (Key in clic)  
		{
		clic[Key]= false;
		document.getElementById(Key).value=valeur_initial[Key];
		document.getElementById(Key).className = "bb";
		document.getElementById(Key).style.background="#FFFFFF";
		}
	}
	



function FermeLesAutres()
	{
	for (Key in clic)  
		{
			//alert ('dans fermelesautres '+document.getElementById(Key).className);
		r=nettoie (document.getElementById(Key).value);
		document.getElementById(Key).value=r;
		document.getElementById(Key).className = "bb";	
		document.getElementById(Key).style.background="#FFFFFF";
		}
	}


function SauveSynFR(tag1)
	{
	var r='';
	//alert('sauvegarde');
	r+= (nettoie(document.getElementById("1").value))+',';
	r+= (nettoie(document.getElementById("2").value))+',';
	r+= (nettoie(document.getElementById("3").value))+',';
	r+= (nettoie(document.getElementById("4").value))+',';
	r+= (nettoie(document.getElementById("5").value));
	r=utf8_encode (r);
	r=escape(r);
	//alert(r);

	lanceAjax ("sauvegarde", "menuajax/SauveAjax.php?tag="+tag1+"&data="+r+"");
//-----------------------------------------------remplace seulement certaines colonnes de la ligne défini par $uit['tag']='amanita virosa'	
		
	//UPDATE `mycoqueb_MycoQue`.`SynFR` SET `synfra1` = 'test',`DerniereCorrection` = NOW( ) WHERE `SynFR`.`ID_S` =1 LIMIT 1 ;
	//Function MaJ ($uit,$ceci, $BanqueMysql,$TableMySQL)
	}


function filtre(oid)

{
	//alert("tabindex"+oid.form.elements.length);
	//alert("tabindex"+oid.form.elements.tabIndex);

var r=oid.value;

vieux=r.substring(0,r.length-1);
dernier=r.charAt(r.length-1);
if ((dernier == "\n"))// \t=tab   \r return \0
	{
			
	
	oid.className = "bb";
	oid.style.background="#FFFFFF";
	for (i = 2; i < oid.form.elements.length; i++)
		if (oid.form.elements[i].tabIndex == oid.tabIndex+1) 
					{
					oid.form.elements[i].focus();
					ilclique(oid.form.elements[i].id);
					}
	}

//alert (liste.indexOf(dernier, 0))

}


	

function utf8_encode ( argString) {
    // Encodes an ISO-8859-1 string to UTF-8  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/utf8_encode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'    
	
	var string = (argString+''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
 
    var utftext = "";
    var start, end;
    var stringl = 0; 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);    }
 
    return utftext;
}


/*-----------------------------------------------FIN -------scripts pour les fonctions des synonymes français */
function MontreListeGroupe(s){
	
if (s=='on') document.getElementById("ListeGroupe").style.display="block";
else document.getElementById("ListeGroupe").style.display="none";
		
}

function entetedelisteP (x) {
document.getElementById("titreABS").innerHTML='#'+x+" "+gr31[x];
document.getElementById("titreABS").style.display="block";	


}

function entetedelisteM (x) {
document.getElementById("titreABS").style.display="none";	
	
}


function lancediapo (id)
	{
	lanceAjax(id, "menuajax/RandomSlide.php");
	setTimeout ("lancediapo(\"diapointro\")",5000);
	}

