function loaded() {
	if (extractQueryParams().confirm) {
		var l_props = defaultProps +
						'resizable=no,' +	//redimensionnement
						'width=510,' +
						'height=330,' +
						'screenX=200,' +		//position horizontale (NS, ne fonctionne pas sur IE)
						'screenY=150,' +
						'left=200,' +		//position horizontale (IE, ne fonctionne pas sur NS)
						'top=150' +
						'scrollbars=no'		//ascenseurs
		var theWindow = window.open("confirmation.htm", "confirmation", l_props); 
	
		if (theWindow) {
			theWindow.focus();
		} else {
			alert(MSG_CONFIRM);
		}
	}
	// on récupère le formulaire
	var l_form = xbGetElementById("contact");
	
	// on spécifie l'url de retour, en utilisant l'url courante
	var l_loc = window.location.href;
	l_form._nextpage.value = l_loc + '?confirm=yes';
}

var _OBLIG = ['a01__Nom_mariee', 'a02__Prenom_mariee', 'a03__Nom_marie', 'a04__Prenom_marie', 
		'a05__Email', 'a06__Telephone_principal', 'a08__Adresse_1', 'a10__Code_postal', 'a11__Ville',
		'a13__Date', 'a14__Lieu', 'a19__services'];
var _LIB = ['mariee', 'mariee', 'marie', 'marie', 
		'mail', 'telephone', 'adresse', 'ville', 'ville',
		'civil', 'civil', 'services'];


/**
 * Renvoie true si la chaîne passée est vide ou ne contient que des 'blancs'
 * @param  s chaîne à tester
 * @return true si chaîne 'vide'
 */
function isBlank(s) {
	if ((s == null) || (s == "")) {
		return true;
	}
	var c;
	for (var i = 0; i < s.length; i++) {
		c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '')) return false;
	}
	return true;
}

/**
 * Renvoie true si la chaîne passée a bien 'une tête de' mail.
 * @param a_strEmail  chaîne à tester
 * @return true si 'tête de' mail
 */
function isValidEmail(a_strEmail){
  var l_validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  if (a_strEmail.search(l_validRegExp) == -1) {
      return false;
  } 
  return true; 
}

function validateContact() {
	var l_form = xbGetElementById("contact");
	var l_ok = true;
	for (var i = 0; i < _OBLIG.length; i++) {
		if (isBlank(l_form[_OBLIG[i]].value)) {
			// on change la css du libellé associé
			xbGetElementById(_LIB[i]).style.color = '#FF0000';
			l_ok = false;
		} else {
			// on change la css du libellé associé (on remet la couleur d'origine)
			xbGetElementById(_LIB[i]).style.color = '';
		}
	}
	if (!l_ok) {
		// on modifie la couleur de la légende
		xbGetElementById('leg').style.color = '#FF0000';
		// on avertit l'utilisateur
		alert(MSG_MAND);
	}
	// on vérifie le mail
	if (l_ok) {
		if (!isValidEmail(l_form[_OBLIG[4]].value)) {
			// on change la css du libellé associé
			xbGetElementById(_LIB[4]).style.color = '#FF0000';
			// on avertit l'utilisateur
			alert(MSG_MAIL);
			l_ok = false;
		} else {
			// on change la css du libellé associé
			xbGetElementById(_LIB[4]).style.color = '';
		}
	}
	// on vérifie le pays de l'adress
	var l_pays = l_form['a12__Pays'];
	if (l_pays.selectedIndex == 0) {
		// on change la css du libellé associé
		xbGetElementById('pays').style.color = '#FF0000';
		l_ok = false;
	} else {
		xbGetElementById('pays').style.color = '';
	}

	// on vérifie le département et le pays du lieu du mariage
	l_pays = l_form['a16__Pays'];
	var l_deptPaysOk = (l_pays.selectedIndex > 0);
	if (l_pays.selectedIndex == INDEX_FRANCE) {
		// france sélectionnée -> on regarde le département
		l_deptPaysOk = (l_form['a15__Departement'].selectedIndex > 0);
	}
	if (!l_deptPaysOk) {
		// on change la css du libellé associé
		xbGetElementById('dept_pays').style.color = '#FF0000';
		l_ok = false;
	} else {
		xbGetElementById('dept_pays').style.color = '';
	}
	
	// on vérifie le choix de la combo
	var l_combo = l_form['a20__Comment'];
	var l_commentOk = (l_combo.selectedIndex > 0);
	if (l_combo.selectedIndex > INDEX_PRECISION) {
		// on vérifie que la précision est renseignée
		l_commentOk = !isBlank(l_form['a21__Precision'].value);
	}
	if (!l_commentOk) {
		// on change la css du libellé associé
		xbGetElementById('comment').style.color = '#FF0000';
		l_ok = false;
	} else {
		xbGetElementById('comment').style.color = '';
	}
	
	return l_ok;
}