function limite(textarea, max)
{
    if(textarea.value.length >= max)
    {
        textarea.value = textarea.value.substring(0,max);
    }
    var reste = max - textarea.value.length;
    var affichage_reste =  reste +' caract&egrave;res restants';
    document.getElementById('max_desc').innerHTML = affichage_reste;
}

function fill(form, input) {
	var bouh= new Array();
	var bah= new Array();
	bouh=["votre_nom", "nom_ami", "email_ami", "votre_email", "votre_message"];
	bah=["Votre nom", "Nom de votre ami", "E-mail de votre ami", "Votre e-mail", "Votre message"];
	for(i=0; i<bouh.length; i++) {
		if(document.getElementById('ami_form').elements[bouh[i]].value=='') {
			document.getElementById('ami_form').elements[bouh[i]].value=bah[i];
		}
		if(bouh[i]==input && document.getElementById('ami_form').elements[input].value==bah[i]) {
			document.getElementById('ami_form').elements[bouh[i]].value='';
		}
	}
	
}

function change_style(id) {
		document.cookie='style='+id; 
		window.location.reload();
		
	}
function getCook(nom) {
        deb = document.cookie.indexOf(nom + "=")
        if (deb >= 0) {
            deb += nom.length + 1
            fin = document.cookie.indexOf(";",deb)
            if (fin < 0) fin = document.cookie.length
            return unescape(document.cookie.substring(deb,fin))
            }
        return ""
}
function getStyle() {
	var StyleFile = getCook('style');
	   if(StyleFile=="") {
		StyleFile=Math.floor(Math.random()*6) ;	
		document.cookie='style='+StyleFile; 	
	   }
	  return StyleFile;
}
