//@DEPRECATED
function repNode(inSTR, inTOK, inREP) {
var s;
s = inSTR + "";

while (s.indexOf(inTOK) >= 0) {
	s = s.replace(inTOK, "?");
};

while (s.indexOf("?") >= 0) {
	s = s.replace("?", inREP);
};

return s;
}

//@DEPRECATED	
function cleanForm(elements)					
{
	for(i = 0; i < elements.length; i++)
	{
		if (elements[i].getAttribute('type') != 'hidden'){
			for (k = 0; k < 32; k++)
			{
				if (k != 9 && k != 10 && k != 13) {
				elements[i].value=repNode(elements[i].value,String.fromCharCode(k),"");
				}
			}		
			elements[i].value=repNode(elements[i].value,"&amp;","tmptmz");
			elements[i].value=repNode(elements[i].value,"&","&amp;");
			elements[i].value=repNode(elements[i].value,"tmptmz","&amp;");	
			elements[i].value=repNode(elements[i].value,"&#123;","?");	
			elements[i].value=repNode(elements[i].value,"&#8216;","?");
			elements[i].value=repNode(elements[i].value,"&#8217;","?");
			elements[i].value=repNode(elements[i].value,"&#8220;","?");
			elements[i].value=repNode(elements[i].value,"&#8221;","?");			
			elements[i].value=repNode(elements[i].value,"&#8364;","?");				
		}			
	}
}
	
function checkForms(longueurDefault)
{

/*var elementsT = document.all ? document.all : document.getElementsByTagName('TEXTAREA');
cleanForm(elementsT);

var elementsI = document.all ? document.all : document.getElementsByTagName('INPUT');
cleanForm(elementsI);
*/				
var Ok=true; 
var theForms = document.getElementsByTagName('TEXTAREA');
var longueur = longueurDefault;
if (theForms != null) {		
	for(i = 0; i< theForms.length; i++) 
		{
		longueur = longueurDefault;
		if (theForms[i].getAttribute("limit") != null && theForms[i].getAttribute("limit") > 0) {longueur = theForms[i].getAttribute("limit")} 
		if (theForms[i].value.length > longueur) {	
			var translate = new Array(theForms[i].value.length, theForms[i].value.substring(0,75), longueur);
			alert(replaceAllVar(translate, lang["cleanForm.error.text"])); 
			Ok=false;
		}
		}			 
	}
	return Ok;
}


function pk_fixnewlines_textarea (val) {             
  // Adjust newlines so can do correct character counting for MySQL. MySQL counts a newline as 2 characters.
  if (val.indexOf('\r\n')!=-1)
    ; // this is IE on windows. Puts both characters for a newline, just what MySQL does. No need to alter
  else if (val.indexOf('\r')!=-1)
  {
    val = val.replace ( /\r/g, "\r\n" );        // this is IE on a Mac. Need to add the line feed
  }
  else if (val.indexOf('\n')!=-1)
  {
    val = val.replace ( /\n/g, "\r\n" );        // this is Firefox on any platform. Need to add carriage return
  }
  else 
    ;                                           // no newlines in the textarea  
  return val;
  }
  
function text_limit_new(len, language )
{
	//on doit stocker le contenu dans une variable pour un decompte correct par javascript
	var textarea = document.getElementById('message');
	var texteareaValue = textarea.value;
	var nbcar = document.getElementById('nbcar');
	var max = 0;
	if (len == 0 || len == null) {
		max = 500;
	} else {
		max = len;
	}
	
	//on ajoute une methode qui remplace les sauts de ligne pour obtenir un fonctionnement
	//correct du decompte des caracteres sur les differents navigateurs
	//comportement souhaité: 2 caracteres comptés par saut de ligne (idem comportement de la base)
	texteareaValue = pk_fixnewlines_textarea(texteareaValue);
	
	
	if (texteareaValue.length > max)
	{
		texteareaValue = texteareaValue.substring(0, max);
		textarea.value = texteareaValue;
	}		
	//taille.value =  max-textearea.value.length;
	var translate = new Array("" + formatInteger( language, max-texteareaValue.length ) + "");
	nbcar.innerHTML = replaceAllVar(translate, lang["testimonials.info.char"]);
}

function verif_text_new(id_champ){
	var textearea = document.getElementById(id_champ);
	var ok = true;
	if (textearea.value.length < 20 || textearea.value.length > 500){
		ok = false;
		alert (lang["testimonials.error.size"]);
	}
	return ok;
}