/** commun.js */

var etoi = {
	pageNode: null
};


/******************* Fonctions utilitaires */

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function checkLengthArea( texte, longueurMax, lang ) {
	if( texte.value.length > longueurMax )
	{
		// message d'avertissement
		var txtTmp;
		if( lang=='en' ){
			txtTmp = "Your message is too long :\nIt should contain less than " + longueurMax + " characters.";
		}
		else {
			txtTmp = "Votre message est trop long :\nIl doit contenir moins de " + longueurMax + " caractères.";
		}
		alert( txtTmp );
		texte.value = texte.value.substring( 0, longueurMax );
	}		
}

//END//

