// JavaScript Document

function aff_user(id){ var url; url='fic_user.php?qcid='+id; window.droite.location.href=url;}
function aff_liste(){ var url; url='liste.php'; window.centre.location.href=url;}
function ChangeMessage(message,champ,serv_img) {if(document.getElementById) document.getElementById(champ).innerHTML = "<img src =" + serv_img +"img/communs/lampe.gif >" + message;}

function inscrit(){var dp; var tsex;var sex;var pos;var chn; var chi;var cod;var mel;var arob;arob='@';var intdt;intdt='_,;!&? éèàùûôâîïëä%#<>[]\£\€\"\'\$';var charok='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
chn=document.jv.pseudo.value; if (document.jv.pseudo.value.length <3) {window.alert('Username too short'); return;}
cod=document.jv.code.value; if (document.jv.code.value.length <3) {window.alert('Password too short'); return;}
dp=document.jv.dpt.value; pos=dp.indexOf('-');if (pos!=-1){window.alert('You must choose a county'); return;}
an=document.jv.annee.value; pos=an.indexOf('-');if (pos!=-1){window.alert('You must input your year of birth'); return;}
if ( (document.jv.sexe[0].checked==false)&& (document.jv.sexe[1].checked==false) ){window.alert('You must indicate your gender'); return;}
mel=document.jv.mail.value; if (document.jv.mail.value.length <7) {window.alert('Email address too short'); return;}
if (document.jv.mail.value.length > 255) {window.alert('Email address too long'); return;}
pos=document.jv.mail.value.indexOf(arob);if (pos==-1) {almsg='Invalid email address';window.alert(almsg);return;}
pos=mel.indexOf('.');if (pos==-1) {almsg='Invalid email address';window.alert(almsg);return;}
for (i=1; i < intdt.length ; i++) {chi=intdt.substr(i,1);pos=mel.indexOf(chi);if (pos !=-1){almsg='Email: The character \"'+chi+'\" is invalid';window.alert(almsg);return;}}
for (i=0; i < chn.length ; i++) {chi=chn.substr(i,1);pos=charok.indexOf(chi);if (pos ==-1){almsg='Pseudo : The character \"'+chi+'\" is invalid';window.alert(almsg);return;}}
for (i=0; i < cod.length ; i++) {chi=cod.substr(i,1);pos=charok.indexOf(chi);if (pos ==-1){almsg='Code : The character \"'+chi+'\" is invalid';window.alert(almsg);return;}}
document.jv.submit();}
