//permet douvrir un nouvel onglet, le tout en accord avec le W3C
function nouvellefenetre(url) {
  window.open(url,"MyPopupWindow","");
}

//fonction de redirection
function redirection(url, delai)
{
	self.setTimeout("self.location.href = '"+url+"';",delai); 
}

function jour(nb_jours, nom)
{
	if(nb_jours >31)
	{
		alert('Jour invalide');
		document.getElementById(nom).value = "";
	}
}

function mois(nb_mois,nom)
{
	if(nb_mois > 12)
	{
		alert('Mois invalide');
		document.getElementById(nom).value = "";
	}
}

function toutCocher(nbLignes, Cas)
{
    var idCase;
    var nom;
    
    for (z=1; z<=nbLignes;z++) // Pour chaque ligne du recueil
	{	
	    if (Cas == 1)
		{
		    idCase = "commune_"+z+"";
		    nom = "tout_cocher_commune";
		}
	    else if(Cas ==2)
		{
		    idCase = "yeux_"+z+"";
		    nom = "tout_cocher_yeux"
			}
	    else if (Cas == 3)
		{
		    idCase = "cheveux_"+z+"";
		    nom = "tout_cocher_cheveux";
		}
	    else if(Cas == 4)
		{
		    idCase = "silhouette_"+z+"";
		    nom = "tout_cocher_silhouette";
		}
	    //Suivant letat on la coche(true) / dÃ©coche(false)
	    if (document.getElementById(nom).checked)
		{
		    document.getElementById(idCase).checked = true;
		}
	    else
		{
		    document.getElementById(idCase).checked = false;
		}
	}
}

function MAJ_Photo(num)
{
    var div;
    var increment;

    increment = 1;
    
    while(increment <=5)
	{   
	    div = "profil"+increment;
	    if(increment == num)
		{
		    document.getElementById(div).style.visibility = 'visible';
		}
	    else
		{
		    document.getElementById(div).style.visibility = 'hidden';
		}
	    increment ++;
	}
}

function recherche(chaine)
{
 	new Ajax.Request('pages/fonction.php?fct=recherche&nom='+chaine, {
  	 method: 'get',
   	onSuccess: function(transport) {
    	 $('retour').innerHTML = transport.responseText;
   		}
 	});
}


function limite(nb,zone,max)
{
	if(zone.value.length>=max)
	{
		zone.value=zone.value.substring(0,max);
		
	}
	if(zone.value.length == max && nb == 1)
	{
		alert('Nombre maximum de caractères atteint');
	}
} 

/*
function BoutonDroit()
{
	if((event.button==2)||(event.button==3)||(event.button==4))
	alert('Click droit a été désactivé');
}
document.onmousedown=BoutonDroit;*/ 