function switchField(boxID,fieldID){
	if(document.getElementById(boxID).checked){
		document.getElementById(fieldID).disabled=0;
	}
	else{
		document.getElementById(fieldID).disabled=1;
		document.getElementById(fieldID).value='';
	}
}

function texteMax(textarea,longueur){
	if(textarea.innerHtml.length>longueur){
		textarea.innerHtml=textarea.innerHtml.substr(0,longueur);
	}
}

function limite(textarea, max, msg)
{ 
    if(textarea.value.length >= max)
    {
        textarea.value = textarea.value.substring(0,max);
    }
    var reste = max - textarea.value.length;
    var affichage_reste =  ' '+ reste +' '+msg;
    document.getElementById('comptelettre').innerHTML = affichage_reste;
}

function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

addLoadEvent(function(){switchField('autreck','autrefi');});
