window.google_analytics_uacct = "UA-739406-3";
// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function Trim( value ) {
	
	return LTrim(RTrim(value));
	
}
function elt(e) 
{ 
	if(document.layers) return document.layers[e];
	if(document.all && !document.getElementById) return document.all[e];
	if(document.all && document.getElementById) return document.getElementById(e);
	if(!document.all && document.getElementById) return document.getElementById(e);
	return null;
}
function newclass(obj,nom)
{
elt(obj).setAttribute('className',nom);
elt(obj).setAttribute('class',nom);
}
function isempty(obj)
{	
	elt(obj).value = Trim(elt(obj).value);
	return (elt(obj).value=='');
}

// Mise a jour du selectedIndex d'une liste
function SelectValeur(L,val) 
{
         for(i=0;i<L.options.length;i++)
            if(L.options[i].value==val) {
               L.selectedIndex=i;
               break;
            }
}
function XMLReq(url,data)
{
			var xhr_object = null;
            
            if(window.XMLHttpRequest) // Firefox
              xhr_object = new XMLHttpRequest();
            else if(window.ActiveXObject) // Internet Explorer
              xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
            else { // XMLHttpRequest non supporte par le navigateur
              alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
              return;
            }

            xhr_object.open("POST", url, true);
            
            xhr_object.onreadystatechange = function() {
              if(xhr_object.readyState == 4)
                eval(xhr_object.responseText);
            }

            xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        	xhr_object.send(data);
}
function param(d,p) { return (d+'='+elt(p).value);}


var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){

if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ 
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder,carac,tropcarac,theid){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all['_'+theid] : document.getElementById('_'+theid)
if (window.event||e.target&&e.target==eval(placeholder)){
placeholderobj.innerHTML='<font class=gris>'+carac+'<b>'+lengthleft+'</b></font>'
if (lengthleft<0)
placeholderobj.innerHTML='<font class=erreur1>'+tropcarac+'</font>'
}
}

function Switch(elem,sorte)
{
	if (sorte==undefined) sorte='block';
	if (elt(elem).style.display==sorte)
	{
		elt(elem).style.display='none';
	}
	else
	{
		elt(elem).style.display=sorte;
	}
}

function sendEmail(encodedEmail)
{
	var email = "";
	for (var i=0; i < encodedEmail.length;)
	{
		var letter = "";
		letter = encodedEmail.charAt(i) + encodedEmail.charAt(i+1)
		email += String.fromCharCode(parseInt(letter,16));
		i += 2;
	}
	location.href = email;
}

function displaylimit(theid, thelimit,carac,tropcarac){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<span id="_'+theid+'"><font class=gris> </font></span>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeydown=function(){ countlimit(thelimit,event,theform,carac,tropcarac,theid)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform,carac,tropcarac,theid)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keydown', function(event) { countlimit(thelimit,event,theform,carac,tropcarac,theid) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform,carac,tropcarac,theid) }, true); 
}
}