function SetCookie(name, value) {
	var argv=SetCookie.arguments;
	var argc=SetCookie.arguments.length;
	var path=(argc > 2) ? argv[2] : null;
	var expires=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
}
function LogOFF(user) {
	if (confirm("Bonjour "+user+" !\nEtes-vous sûr de vouloir vous déconnecter ?")) {
		window.location="index.php?logoff="+user;
	}
}
function annonce_CheckInsert(f) {
	var ok=1;
	if ((ok==1)&&(f.titre.value=="")){alert("Vous devez saisir un titre à votre annonce..."); f.titre.focus(); ok=0;}
	if ((ok==1)&&( (isNaN(f.prix.value)) || (f.prix.value=="") ) ){alert("Vous devez saisir un prix valide..."); f.prix.focus(); ok=0;}
	if ((ok==1)&&(f.pays.options[f.pays.selectedIndex].value=="FRANCE")){ 
		if ( (f.codepostal.value=="") || (isNaN(f.codepostal.value)) || ! ((f.codepostal.value.length==5) || (f.codepostal.value.length==2) ) ){alert("Vous devez saisir un code postal ou un département valide..."); f.codepostal.focus(); ok=0;}
	}
	if ((ok==1)&&(f.description.value=="")){alert("Vous devez saisir une description de votre annonce..."); f.description.focus(); ok=0;}
	if ((ok==1)&&(f.accepter.checked==false)){alert("Vous devez accepter les règles d'utilisation du service..."); f.accepter.focus(); ok=0;}
	if (ok==1) {f.submit()}
}
function ViewUser(user) {
	var w=window.open("../forums/viewuser.php?user="+user,"user","width=450,height=400,menubar=no,scrollbar=no");
	w.focus();
}
function annonce_CheckMessage(f) {
	var ok=1;
	if ((ok==1)&&(f.email.value=="")){alert("Vous devez saisir votre mail..."); f.email.focus(); ok=0;}
	if ((ok==1)&&(f.message.value=="")){alert("Vous devez saisir un message..."); f.message.focus(); ok=0;}
	if (ok==1) {f.submit()}
}
function InsererAnnonce() {
	if (IDcat!=0) {
		window.location="index.php?inserer="+IDcat;
	} else {
		window.location="index.php?aide=1";
	}
}
function MsgErreur(Ligne1,Ligne2) {
	if (Ligne2==null)	{Ligne2="";	}
	var nb=Math.max(Ligne1.length,Ligne2.length);
	var msg="E R R E U R !";
	var space="";
	for (var i=0;i<=(nb-msg.length)/2+1;i++)	{space+=" "}
	alert(space+" "+msg+"\n"+Ligne1+"\n"+Ligne2);
}
function CheckRegister(f) {
	var exp=new RegExp("^[\.a-zA-Z0-9ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ_\-]{3,20}$","g");
	var ok=1
	if (!exp.test(f.login.value) ) {MsgErreur("Le login n'est pas valide !","Il doit faire de 3 à 20 caractères sans caractères spéciaux.");f.login.focus();ok=0 }
	if ((ok==1)&&(f.password.value.length<5)){MsgErreur("Le mot de passe doit faire au moins 5 caractères !");f.password.focus();ok=0; 	}
	if ((ok==1)&&(f.password.value!=f.password2.value)){MsgErreur("Le mot de passe n'est pas confirmé correctement !");f.password2.focus();ok=0; 	}
	exp=new RegExp("^[a-zA-Z0-9\-_-]+[a-zA-Z0-9\.\-_-]*@[a-zA-Z0-9\-_]+\.[a-zA-Z\.\-_]{2,}","g");
	if ((ok==1)&&(!exp.test(f.email.value)) ) {MsgErreur("L'adresse mail n'est pas valide !","Vous devez saisir une adresse mail valide pour confirmer votre inscription.");f.email.focus();ok=0 }
	if (ok==1)	{ f.bouton.value="En cours..."; f.submit();	}
}



var IDcat=0;
var PasserAnnonceMsg="Besoin d'aide ?";