/*
*	ekoya-2207
*	javascript document
*/

//========== DECOMPTE CARACTERES TEXTAREA =========

var nbLettre = 0

function test(e){
	if (estTouche (e)){
		if ((this.value.length + 1) > this.lettreMax ){
			Event.stop(e);
		}
	}
	str = $F(this)
	if (str.length >this.lettreMax){
		str = str.truncate(this.lettreMax , ""); // securité au cas au ou trop de lettre on été saisie
		this.value = str; 
	}
}

function estTouche(e){
 	if (e.keyCode > 46 && !estToucheVide(e) || e.keyCode==32){
 		return true;
	}
 	else{
 		return false;
	}
}

function estToucheVide(e){
	if ((e.keyCode >=112 && e.keyCode <=123) && e.keyCode == 92 && e.keyCode == 93 ){
		return true;
	}
	else{
		return false;
	}
}

function compValeur(e){
	nbLettre = this.lettreMax - $F(this).length
	if (nbLettre <0 ){
		nbLettre = 0 ;
	}
	str = $F(this);
	if (str.length >this.lettreMax){
		str = str.truncate(this.lettreMax , ""); // securité au cas au ou trop de lettre on été saisie
		this.value = str;
	}
	$(this.limite).innerHTML = nbLettre;
	Event.stop(e);
}
