function initselection(formulaire)
{

	for(i=0;i<=formulaire.nb_element.value;i++)
	{
		if(formulaire.elements[0].type=="select-one")formulaire.elements[i].options[0].selected= true;
	}
	formulaire.submit();
}

function compte_car(formulaire,base)
{
	if(base-Number(formulaire.message.value.length)<0)
	{
		alert("Attention, votre message est trop long.");
		formulaire.message.value=formulaire.message.value.substr(0,base);
	}
	formulaire.nbcar.value=base-Number(formulaire.message.value.length);
}

function is_caractere(champ)
{
	if(champ.indexOf('\'')!=-1) return false;
	if(champ.indexOf('/')!=-1) return false;
	if(champ.indexOf('\"')!=-1) return false;
	if(champ.indexOf(' ')!=-1) return false;
	if(champ.indexOf('\\')!=-1) return false;
	return true;
}

function is_pseudo(champ)
{
	if(champ.length<2 || champ.length>12)return false;
	if(champ.indexOf("°")!=-1) return false;
	if(champ.indexOf("ç")!=-1) return false;
	if(champ.indexOf("à")!=-1) return false;
	if(champ.indexOf("~")!=-1) return false;
	if(champ.indexOf(";")!=-1) return false;
	if(champ.indexOf(":")!=-1) return false;
	if(champ.indexOf("!")!=-1) return false;
	if(champ.indexOf("(")!=-1) return false;
	if(champ.indexOf(",")!=-1) return false;
	if(champ.indexOf("[")!=-1) return false;
	if(champ.indexOf(")")!=-1) return false;
	if(champ.indexOf("]")!=-1) return false;
	if(champ.indexOf("=")!=-1) return false;
	if(champ.indexOf("{")!=-1) return false;
	if(champ.indexOf("}")!=-1) return false;
	if(champ.indexOf("%")!=-1) return false;
	if(champ.indexOf("$")!=-1) return false;
	if(champ.indexOf("£")!=-1) return false;
	if(champ.indexOf("^")!=-1) return false;
	if(champ.indexOf("¨")!=-1) return false;
	if(champ.indexOf("§")!=-1) return false;
	if(champ.indexOf(">")!=-1) return false;
	if(champ.indexOf("<")!=-1) return false;
	if(champ.indexOf("|")!=-1) return false;
	if(champ.indexOf("`")!=-1) return false;
	if(champ.indexOf("µ")!=-1) return false;
	if(champ.indexOf("ù")!=-1) return false;	
	if(champ.indexOf("/")!=-1) return false;
	if(champ.indexOf("ê")!=-1) return false;
	if(champ.indexOf("è")!=-1) return false;
	if(champ.indexOf("é")!=-1) return false;
	if(champ.indexOf("?")!=-1) return false;
	if(champ.indexOf("&")!=-1) return false;
	if(champ.indexOf("#")!=-1) return false;
	if(champ.indexOf("'")!=-1) return false;
	if(champ.indexOf(" ")!=-1) return false;
	if(champ.indexOf("\\")!=-1) return false;
	if(champ.indexOf("\"")!=-1) return false;
	if(champ.indexOf("*")!=-1) return false;
	if(champ.indexOf("+")!=-1) return false;
	if(champ.indexOf("(")!=-1) return false;
	if(champ.indexOf(")")!=-1) return false;
	if(champ.indexOf("à")!=-1) return false;
	if(champ.indexOf("@")!=-1) return false;
	if(champ.indexOf("¬")!=-1) return false;
	if(champ.indexOf("û")!=-1) return false;
	return true;
}

function is_mail(champ)
{
	if(champ.length==0)return false;
	if(champ.indexOf('\'')!=-1) return false;
	if(champ.indexOf('/')!=-1) return false;
	if(champ.indexOf('\\')!=-1) return false;
	if(champ.indexOf(':')!=-1) return false;
	if(champ.indexOf(';')!=-1) return false;
	if(champ.indexOf('\"')!=-1) return false;
	if(champ.indexOf(' ')!=-1) return false;
	if(champ.indexOf(',')!=-1) return false;
	if(champ.indexOf('?')!=-1) return false;
	if(champ.indexOf('#')!=-1) return false;
	if(champ.indexOf('&')!=-1) return false;
	if(champ.indexOf('@')<2) return false;
	if(champ.indexOf('é')!=-1) return false;
	if(champ.indexOf('è')!=-1) return false;
	temp=champ.substr(champ.indexOf('@'));
	if(temp.toLowerCase()=="@pa")return true;
	if(champ.substr(champ.indexOf('@')).indexOf('.')<2) return false;
	if(temp.substr(temp.indexOf('.')).length<2) return false;
	return true;
}

function is_date(dateentree)
{
	if(dateentree=="")return false;
	if(dateentree.indexOf("-")!=-1)return false;
	if(dateentree.length<8 || dateentree.length>10)return false;
	if(dateentree.indexOf("+")!=-1)return false;
	if(dateentree.indexOf("/")!=2)return false;
	if(dateentree.lastIndexOf("/")!=5)return false;
	detail=dateentree.split("/");

	if(detail[2].length==2)
	{
		annee=(Number(detail[2])>30) ? "19"+detail[2]:"20"+detail[2];
	}
	else
	{
		annee=detail[2];
	}
	dateentree=detail[0]+"/"+detail[1]+"/"+annee;
	newdate= new Date();
	newdate.setFullYear(Number(annee),Number(detail[1])-1,Number(detail[0]));
	oldyeardate= Number(newdate.getFullYear().toString().substr(0,4));
	oldmonthdate= newdate.getMonth()+1;
	olddaydate= newdate.getDate();
	return ((Number(oldyeardate)==Number(annee))&&(Number(oldmonthdate)==Number(detail[1]))&&(Number(olddaydate)==Number(detail[0]))&&(dateentree.length==10));
}

function reset_type(formulaire,choix)
{
	if(choix==1)formulaire.autretype.value="";
	if(choix==2)formulaire.type.selectedIndex=0;
}

function reset_categorie(formulaire,choix)
{
	if(choix==1)formulaire.autrecategorie.value="";
	if(choix==2)formulaire.categorie.selectedIndex=0;
}

function verif_utilisateur(formulaire,langue,fenetre)
{
	if(formulaire.password_utilisateur.value=="" || formulaire.login_utilisateur.value=="")
	{
		alert("Vous devez entrer votre login et votre password.");
		return;
	}
	window.open('',fenetre,'width=400,height=350');
	formulaire.submit();
}

function confirmation_new_password(formulaire)
{
	if(formulaire.login_jeux.value=="" || formulaire.old_password.value=="" || formulaire.new_password.value=="" || formulaire.confnew_password.value=="")
	{
		alert("Tous les champs sont obligatoires.");
		return;
	}
	if(formulaire.new_password.value!=formulaire.confnew_password.value)
	{
		alert("Le nouveau mot de passe est différent de la confirmation.");
		return;
	}
	formulaire.validation_jeux.value="ok";
	formulaire.submit();
}