// choix de destinataire
function choixmail() {
var doc = document.form;
doc.i_comment.value = "";
var x = doc.sujet.selectedIndex;
var n = doc.sujet[x].value; doc.i_sujet.value = doc.sujet[x].text;
//inscriptions
if (( n > 100) && ( n < 200)){
	doc.i_dest.value = "fens2008@mci-group.com";
	doc.action = "/php/contactsFens.php";
	if (n == 101) { a = "Registration - submission";}
	if (n == 102) { a = "Registration - cancellation";}
	if (n == 103) { a = "credit card payment"; doc.i_dest.value = "forum2008@fensforum.eu";}
	if (n == 104) { a = "Registration - other payments";}
	if (n == 105) { a = "Registration - other questions";}
	doc.i_sujet.value = a;
	}
//abstracts
if (( n > 200) && ( n < 300)){
	doc.i_dest.value = "forum2008@fensforum.eu";
	doc.action = "/php/contactsFens.php"; var a = "";
	if (n == 201) { a = "Abstract submission";}
	if (n == 202) { a = "Abstract cancellation";}
	if (n == 203) { a = "Abstract - other questions";}
	doc.i_sujet.value = a;
	}
//technique
if( n == 500) {
	doc.i_dest.value = "forum2008@fensforum.eu";
//	doc.i_dest.value = "jean-francis.renaudon@inserm.fr";
	doc.action = "/php/contactsFens.php";
	doc.i_sujet.value = "Technical problem";
	}
//hotel
if (( n > 300) && ( n < 400)){
	doc.i_dest.value = "fens2008@mci-group.com";
	doc.action = "/php/contactsFens.php";
	if (n == 301) { a = "Hotel booking";}
	if (n == 302) { a = "Hotel - cancellation";}
	if (n == 303) { a = "Social events";}
	if (n == 304) { a = "Special interest socials";}
	if (n == 305) { a = "Excursions";}
	if (n == 306) { a = "Meeting room rental";}
	doc.i_sujet.value = a;
	}
//mot de passe: codes d'acces
if( n == 400) {
	alert("Warning: name, registration number and Email address must correspond exactly to those you registered.");
	doc.i_dest.value = "";
	doc.action = "/4DLINK11/4DCGI/Inscr.mdp";
	}
//exposants
if (n == 600){
	doc.i_dest.value = "kris@herlitz.com";
	doc.action = "/php/contactsFens.php";
	doc.i_sujet.value = "Exhibition";
	}
//autres
if (n >= 700){
	doc.i_dest.value = "fens2008@mci-group.com";
	doc.action = "/php/contactsFens.php";
	if (n == 701) { a = "Request for invitation letter"; messinvite();}
	if (n == 702) { a = "Request for invoice";}
	if (n == 703) { a = "Request for receipt of payment";}
	if (n == 704) { a = "Miscellaneous";}
	if (n == 705) { a = "Problem with FENS membership"; doc.i_dest.value = "a.buchheister@mdc-berlin.de";}
	doc.i_sujet.value = a;
	}
//press
if (n == 800){
	doc.i_dest.value = "elaine@snell-communications.net";
	doc.action = "/php/contactsFens.php";
	doc.i_sujet.value = "Press invitation";
	}
//court-circuite destinataire pour test
//doc.i_dest.value = "dominique.poulain@bordeaux.inserm.fr";
}

//dernier controle
function verifcontact() {
var doc = document.form;
var x = doc.sujet.selectedIndex; n = doc.sujet[x].value;

if (x == 0) {alert("Select a subject.");return false;}
if ( doc.i_nom.value == "") {alert("Name is mandatory.");return false;}
if (mail() == false) {return false;}
if ((n == 400) && (doc.i_inscrnum.value == "")) {alert("The registration number is mandatory.");return false;}
if (doc.i_inscrnum.value == "") {
 if (confirm("The registration number is necessary for most queries.\n"+"Click on Cancel and type it in, or click on OK to send your message without it.") == false) {return false;}
 }
doc.contr.value = ""; 
if (comment() == false) {return false;}
return true;
}

//Pas de message pour mot de passe
function comment() {
var doc = document.form;
var x = doc.sujet.selectedIndex; var n = doc.sujet[x].value;
if ((n == 400) && (doc.i_comment.value.length > 1)) {
 alert("No message needed here, automatic reply.");
 doc.i_comment.value = "";return false;
 }
}

//verifie le format du mail
function mail() {
 var d = document.form.i_email.value.toLowerCase();
 if( d == "") {messerreur("Adresse mel ?","Please type in your E-mail address");return false;}
 var correct = true;
 var dnuk ="Incorrect syntax in e-mail address: ";
 var dnfr ="Syntaxe incorrecte dans l'adresse mel : ";
 var x = d.indexOf("@")
 if (x < 0) {dnuk = dnuk+" missing @\n";dnfr = dnfr+" il manque le @\n";messerreur(dnfr,dnuk); return false;}
 if (x == d.length-1) {messerreur(dnfr,dnuk); return false;}
 var x = d.indexOf(".")
 if (x < 0) {dnuk = dnuk+" missing '.'\n"; dnfr = dnfr+" il manque le '.'\n"; messerreur(dnfr,dnuk); return false;}
 if (x == d.length-1) {messerreur(dnfr,dnuk); return false;}
 var autorise="abcdefghijklmnopqrstuvwxyz0123456789_.-@";
 for (i=0; i< d.length; i++) {
    if (autorise.indexOf(d.charAt(i)) < 0) {correct = false;}
 }
 if (correct) {return true;}
 dnuk = dnuk+" bad characters in address.\n"; 
 dnfr = dnfr+" caractere interdit dans une adresse mel.\n";
 messerreur(dnfr,dnuk);
 return false;
}//fin

//pre-remplit la demande d'invitation
function messinvite() {return;
 alert("Please complete the requested information before sending.");
 doc = document.form;
 var a = "Will you please send me a letter of invitation with the following information:\n\n";
 a = a +"Last name:"+"\n";
 a = a +"First name:"+"\n";
 a = a +"Date of birth:"+"\n";
 a = a +"Passport number:"+"\n";
 a = a +"Passport valid until:"+"\n";
 a = a +"Country of origin:"+"\n";
 a = a + "\n" + "With my thanks"+"\n";
 doc.i_comment.value = a;
}

// messerreur en anglais ou francais
function messerreur(fr,uk) {
 doc = document.form;
 if (doc.i_lang.value == "FR") {alert(fr);} else {alert(uk);}
}
//Ne partira que si tout est correct
function go() {
 doc = document.form;
 if(doc.contr.value != "") {return false;}
 doc.contr.value = "*"; return true;
} //fin


