﻿
function pop_it(the_form) {
   my_form = eval(the_form);
   window.open("/_DM/wait.php", "popup", config='height=100, width=900, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no, dependent=yes');
   my_form.target = "popup";
   my_form.submit();
}

function initMsg(lang) {

	if (lang =="ru"){
		msgGenre = "Господин или Госпожа ?";
		msgNom = "Ваша фамилия ?";
		msgPrenom = "Ваше имя ?";
		msgAdresse = "Ваш почтовый адрес ?";
		msgCode = "Ваш почтовый код ?";
		msgPays = "Ваша страна ?";
		msgEmail = "Ваш e-mail ?";
		msgPayement = "Выбрать способ оплаты ?";
		msgEmail_1 = 'Ваш электронный адрес содержит неверные символы. Проверьте, пожалуйста.'
		msgEmail_2 = 'Ваш электронный адрес не содержит знак @. Проверьте, пожалуйсте.'
		msgEmail_3 = 'Адрес должен содержать только один знак @. Проверьте, пожалуйста. '
		msgEmail_4 = 'Вы забыли знак точки "." после знака "@". Проверьте, пожалуйста.'
		msgEmail_5 = 'После знака точки "." нужно поставить еще как минимум два символа. Проверьте, пожалуйста.'
	}
	else if (lang == "it"){ 
		msgGenre = "Signora o Signore ?";
		msgNom = "Cognome ?";
		msgPrenom = "Nome ?";
		msgAdresse = "Indirizzo ?";
		msgCode = "Codice Postale ?";
		msgPays = "Paese ?";
		msgEmail = "Email ?";
		msgPayement = "Pagamento ?";
		msgEmail_1 = 'L\'email contiene caratteri invalidi.'
		msgEmail_2 = 'L\'email non contiene il segno "@".'
		msgEmail_3 = 'L\'email deve contenere solo un segno "@".'
		msgEmail_4 = 'L\'email deve contenere un punto "." dopo il segno "@".'
		msgEmail_5 = 'L\'email deve contenere almeno due caratteri dopo il segno ".".'
	}
	else {
		msgGenre = "Madame ou Monsieur ?";
		msgNom = "Votre Nom SVP";
		msgPrenom = "Votre Prenom SVP";
		msgAdresse = "Votre Adresse SVP";
		msgCode = "Votre Code Postal SVP";
		msgPays = "Votre Pays SVP";
		msgEmail = "Votre Email SVP";
		msgPayement = "Choisir un mode de payement SVP";
		msgEmail_1 = 'Votre e-mail contient des caracteres invalides. Veuillez verifier.'
		msgEmail_2 = 'Votre e-mail ne contient pas le signe "@". Veuillez verifier.'
		msgEmail_3 = 'Votre e-mail ne doit contenir qu\'un signe "@". Veuillez verifier.'
		msgEmail_4 = 'Votre e-mail doit contenir un point "." apres le signe "@". Veuillez verifier.'
		msgEmail_5 = 'Votre e-mail doit contenir au moins deux caracteres apres le signe ".". Veuillez verifier.'
	}
	
}


function verifSelection(the_form, lang) {

my_form = eval(the_form);
initMsg(lang);
a=0;
t="";
l="\n"

nbreboutons2 = document.mail_form.genre.length
	flag = 0
		for (i = 0; i < nbreboutons2 ; i++) {

			if (document.mail_form.genre[i].checked) {

			flag = 1

			}

		}

if (flag == 0) {

t=t+msgGenre+ l;
a=1;
}

if (document.mail_form.nom.value == "") {
t=t+ msgNom + l;
a=1;
} 

if (document.mail_form.prenom.value == "") {
t=t+ msgPrenom + l;
a=1;
} 

if (document.mail_form.adresse.value == "") {
t=t+ msgAdresse + l;
a=1;
} 

if (document.mail_form.code.value == "") {
t=t+ msgCode + l;
a=1;
} 

if (document.mail_form.pays.value == "") {
t=t+msgPays+ l;
a=1;
} 

if (document.mail_form.email.value == "") {
t=t+msgEmail+ l;
a=1;
}

nbreboutons1 = document.mail_form.payement.length

	flag = 0

		for (i = 0; i < nbreboutons1 ; i++) {

			if (document.mail_form.payement[i].checked) {

			flag = 1

			}

		}


if (flag == 0) {

t=t+msgPayement+ l;
a=1;
}


if (a == 0) {

	invalidChars = " /:,;'"

	for (i=0; i < invalidChars.length; i++) {	// does it contain any invalid characters?
	badChar = invalidChars.charAt(i)

	if (document.mail_form.email.value.indexOf(badChar,0) > -1) {
	alert(msgEmail_1)
	document.mail_form.email.focus()
	return false
	}
	}

	atPos = document.mail_form.email.value.indexOf("@",1)			// there must be one "@" symbol
	if (atPos == -1) {
	alert(msgEmail_2)
	document.mail_form.email.focus()
	return false
	}

	if (document.mail_form.email.value.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
	alert(msgEmail_3)
	document.mail_form.email.focus()
	return false
	}

	periodPos = document.mail_form.email.value.indexOf(".",atPos)

	if (periodPos == -1) {					// and at least one "." after the "@"
	alert(msgEmail_4)
	document.mail_form.email.focus()
	return false
	}

	if (periodPos+3 > document.mail_form.email.value.length)	{		// must be at least 2 characters after the 
	alert(msgEmail_5)
	document.mail_form.email.focus()
	return false
	}
}


if (a==0){
	pop_it(my_form);
}
else {
	alert(t);
}

} // Fin de la fonction
